[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] Need a little C programming help

On Mon, Sep 11, 2006 at 05:44:37PM -0500, Mike Reinehr wrote:
> My apology for taking up the groups time with an off-topic request for help. I 
> don't think that this has anything at all to do with 64-bit processing. What 
> I know about c programming wouldn't take me five minutes to tell, so I'm 
> easily stumped by compiler error messages.
> I have a very small c program that is running on our local AMD64 server, which 
> is running an up to date Debian Sarge. I've compiled this program many times 
> over the past year by simply typing `cc swrc.c` and then weeding out my many 
> c errors.
> This evening, I had to make very minor change to the program but when I 
> attempted to compile I received the following error output:
> cmr@gladsheim:~/tmp$ cc swrc.c

Try gcc -Wall instead, that gives you a lot more hints about what's

> In file included from /usr/include/sys/types.h:219,
>                  from /usr/include/stdlib.h:433,
>                  from swrc.c:5:
> /usr/include/sys/sysmacros.h: In function `main':
> /usr/include/sys/sysmacros.h:43: error: nested function `gnu_dev_major' 
> declared `extern'
> /usr/include/sys/sysmacros.h:49: error: nested function `gnu_dev_minor' 
> declared `extern'
> /usr/include/sys/sysmacros.h:55: error: nested function `gnu_dev_makedev' 
> declared `extern'
> cmr@gladsheim:~/tmp$

Nested functions? Looks like you're including a header file in a
function instead of outside of it. If you know what you're doing it
shouldn't be a problem, but as a general rule don't even try that.

> I would really appreciate someone telling me what I'm doing wrong, or at least 
> giving me a hint!

Always compile with -Wall. Adding -Wshadow sometimes also reveals
interesting bugs.


+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands

Reply to: