View Single Post
  #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