DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 12th July 2008
Dr_Death_UAE's Avatar
Dr_Death_UAE Dr_Death_UAE is offline
BSD Daemon
 
Join Date: Jul 2008
Posts: 9
Default u_char under FreeBSD gcc

Hello, i was trying to compile c code with freebsd gcc 4.2.1, but it give me error related to u_char

Code:
$gcc -Wall -o file file.c
file.c: In function 'numb':
file.c:102: error: 'u_char' undeclared (first use in this function)
file.c:102: error: (Each undeclared identifier is reported only once
file.c:102: error: for each function it appears in.)
file.c:102: error: expected ';' before 'a'
file.c:105: error: 'a' undeclared (first use in this function)
file.c:106: error: 'b' undeclared (first use in this function)
file.c:107: error: 'c' undeclared (first use in this function)
file.c:108: error: 'd' undeclared (first use in this function)
under linux it compile and run fine, this the u_char source code part:

Code:
char *numb(unsigned long num, char *buf)
{
    u_char a, b, c, d;

    memset(buf, 0x00, 16);
    a = (int)(num / 16777216) % 256;
    b = (int)(num / 65536) % 256;
    c = (int)(num / 256) % 256;
    d = (int)num % 256;

    sprintf(buf, "%d.%d.%d.%d",a,b,c,d);
    return(buf);
}
any idea how to make it run under BSD?

thanks
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick