__STDC__ - Can I undef ?

__STDC__ - Can I undef ?

Post by Wayne Pasco » Tue, 19 Feb 2002 22:05:54



I am currently building something on Solaris 8 that uses sys/mnttab.h

I tried building this and got the following make errors:
In file included from check_fs_type.c:10:
/usr/include/sys/mnttab.h:62: parse error before `*'
/usr/include/sys/mnttab.h:63: parse error before `*'
/usr/include/sys/mnttab.h:64: parse error before `*'
/usr/include/sys/mnttab.h:65: parse error before `*'

Looking at the file shows the following:
#ifdef __STDC__
extern void resetmnttab(FILE *);
extern int  getmntent(FILE *, struct mnttab *);
extern int  getextmntent(FILE *, struct extmnttab *, size_t);
extern int  getmntany(FILE *, struct mnttab *, struct mnttab *);
extern char *hasmntopt(struct mnttab *, char *);
extern char *mntopt(char **);
#else
extern void resetmnttab();
extern int  getmntent();
extern int  getextmntent();
extern int  getmntany();
extern char *hasmntopt();
extern char *mntopt();                                        
#endif

Seeing this, I added a line to my config.h saying
#undef __STDC__

now the application builds (and appears to run) ok, but there are
LOADS of warnings. Basically, every file that includes config.h
produces the following warning at compile time :

In file included from config_opts.c:8:
config.h:19: warning: undefining `__STDC__'

What is the right way to
a) detect, preferably with autoconf as to whether this should be
defined or not
and
b) disable this without causing warnings to spew forth.

TIA,

--
- Wayne Pascoe
                                 | There are no stupid questions,

http://www.penguinpowered.org.uk |

 
 
 

__STDC__ - Can I undef ?

Post by Maurice F » Tue, 19 Feb 2002 23:13:09



>I am currently building something on Solaris 8 that uses sys/mnttab.h

>I tried building this and got the following make errors:
>In file included from check_fs_type.c:10:
>/usr/include/sys/mnttab.h:62: parse error before `*'
>/usr/include/sys/mnttab.h:63: parse error before `*'
>/usr/include/sys/mnttab.h:64: parse error before `*'
>/usr/include/sys/mnttab.h:65: parse error before `*'

>Looking at the file shows the following:
>#ifdef __STDC__
>extern void resetmnttab(FILE *);
>extern int  getmntent(FILE *, struct mnttab *);
>extern int  getextmntent(FILE *, struct extmnttab *, size_t);
>extern int  getmntany(FILE *, struct mnttab *, struct mnttab *);
>extern char *hasmntopt(struct mnttab *, char *);
>extern char *mntopt(char **);
>#else
>extern void resetmnttab();
>extern int  getmntent();
>extern int  getextmntent();
>extern int  getmntany();
>extern char *hasmntopt();
>extern char *mntopt();                                        
>#endif

>Seeing this, I added a line to my config.h saying
>#undef __STDC__

>now the application builds (and appears to run) ok, but there are
>LOADS of warnings. Basically, every file that includes config.h
>produces the following warning at compile time :

>In file included from config_opts.c:8:
>config.h:19: warning: undefining `__STDC__'

>What is the right way to
>a) detect, preferably with autoconf as to whether this should be
>defined or not
>and
>b) disable this without causing warnings to spew forth.

>TIA,

>--
>- Wayne Pascoe
>                                 | There are no stupid questions,

>http://www.penguinpowered.org.uk |

WARNING:  This answer is unencumbered by any factual knowledge, so
no flames, please.

When I was faced with something vaguely similar a while back, I found
that the offending line in an #included header depended upon a prior
definition from a different header that was not automatically #included.  
I changed the app code to #include the other header, and voila! the
problem was gone.  

So, I'd suggest taking a look at lines 62-64 of mnttab.h for any potentially
undefined variable or what have you, then looking for a definition of such
in the other headers provided by the system and the compiler using find
and grep.  It would probably be useful to run the program through the
preprocessor and looking at the preprocessor output instead of the raw
code.

HTH - Maurice

 
 
 

__STDC__ - Can I undef ?

Post by Wayne Pasco » Wed, 20 Feb 2002 00:13:18



> >Looking at the file shows the following:
> >#ifdef __STDC__
> >extern void resetmnttab(FILE *);
> >extern int  getmntent(FILE *, struct mnttab *);
> >extern int  getextmntent(FILE *, struct extmnttab *, size_t);
> >extern int  getmntany(FILE *, struct mnttab *, struct mnttab *);
> >extern char *hasmntopt(struct mnttab *, char *);
> >extern char *mntopt(char **);
> >#else
> >extern void resetmnttab();
> >extern int  getmntent();
> >extern int  getextmntent();
> >extern int  getmntany();
> >extern char *hasmntopt();
> >extern char *mntopt();                                        
> >#endif

> >Seeing this, I added a line to my config.h saying
> >#undef __STDC__

> WARNING:  This answer is unencumbered by any factual knowledge, so
> no flames, please.

> When I was faced with something vaguely similar a while back, I found
> that the offending line in an #included header depended upon a prior
> definition from a different header that was not automatically #included.  
> I changed the app code to #include the other header, and voila! the
> problem was gone.  

> So, I'd suggest taking a look at lines 62-64 of mnttab.h for any potentially
> undefined variable or what have you, then looking for a definition of such
> in the other headers provided by the system and the compiler using find
> and grep.  It would probably be useful to run the program through the
> preprocessor and looking at the preprocessor output instead of the raw
> code.

Looking at the lines in question, there appears to be a difference in
the function prototype for when you have __STDC__ defined and when you
don't. For example:
extern void resetmnttab(FILE *); throws an error while
extern void resetmnttab(); doesn't

A sample chunk of code that I wrote to test the getmntent
functionality on solaris didn't complain at all about this during a
gcc -g file.c -o file, it is only when it is included with my app that
this happens.

how would I run this through the preprocessor as per your suggestion ?

Thanks,

--
- Wayne Pascoe
                                 | I haven't lost my mind...

http://www.penguinpowered.org.uk |

 
 
 

__STDC__ - Can I undef ?

Post by Alex » Wed, 20 Feb 2002 02:13:39



Quote:> I am currently building something on Solaris 8 that uses sys/mnttab.h

> I tried building this and got the following make errors:
> In file included from check_fs_type.c:10:
> /usr/include/sys/mnttab.h:62: parse error before `*'
> /usr/include/sys/mnttab.h:63: parse error before `*'
> /usr/include/sys/mnttab.h:64: parse error before `*'
> /usr/include/sys/mnttab.h:65: parse error before `*'

> Looking at the file shows the following:
> #ifdef __STDC__
> extern void resetmnttab(FILE *);
> extern int  getmntent(FILE *, struct mnttab *);
> extern int  getextmntent(FILE *, struct extmnttab *, size_t);
> extern int  getmntany(FILE *, struct mnttab *, struct mnttab *);
> extern char *hasmntopt(struct mnttab *, char *);
> extern char *mntopt(char **);
> #else
> extern void resetmnttab();
> extern int  getmntent();
> extern int  getextmntent();
> extern int  getmntany();
> extern char *hasmntopt();
> extern char *mntopt();
> #endif

> Seeing this, I added a line to my config.h saying
> #undef __STDC__

> now the application builds (and appears to run) ok, but there are
> LOADS of warnings. Basically, every file that includes config.h
> produces the following warning at compile time :

> In file included from config_opts.c:8:
> config.h:19: warning: undefining `__STDC__'

> What is the right way to
> a) detect, preferably with autoconf as to whether this should be
> defined or not
> and
> b) disable this without causing warnings to spew forth.

Is FILE defined? Are you including stdio.h?

Alex

 
 
 

__STDC__ - Can I undef ?

Post by Andrew Giert » Wed, 20 Feb 2002 06:43:31


 Wayne> Looking at the lines in question, there appears to be a
 Wayne> difference in the function prototype for when you have
 Wayne> __STDC__ defined and when you don't.

no, what it's doing is _omitting_ the prototype when __STDC__ is not
defined, in order to cope with K&R compilers.

 Wayne> For example:
 Wayne> extern void resetmnttab(FILE *); throws an error while

probably because you didn't include <stdio.h>.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
                           or <URL: http://www.whitefang.com/unix/>

 
 
 

1. Why are lots of typedefs not defined unless __STDC__ == 0 on Solaris 2.6?

I've been working on a program to display process trees dynamically to
work non-suid for Solaris 2.6 and up. I've been getting compiler
errors with egcs (the only compiler I have and have tried) because
lots of typedefs are missing such as for sigset_t and uint64_t (used
by "sys/procfs.h").

In /usr/include/sys/int_types.h we have
#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
typedef unsigned long long      uint64_t;
#endif

Looking at /usr/include/sys/signal.h we have:

#if defined(__EXTENSIONS__) || (__STDC__ - 0 == 0) || ...

Actually, the C-Preprocssor logic for sigset_t in sys/signal.h is
so complicated that I really have a hard time pinpointing why it is
not defined, other than knowing that you can #define __EXTENSIONS__ or
#define __STDC__ 0 and that will work.

Anyway, the question is what are the various meanings of the values of
__STDC__? Is this documented somewhere?

2. Reading is much more interesting than TV (0456/1708)

3. __STDC__?

4. Two issues; pkg use and pkg format

5. Why are lots of typedefs not defined unless __STDC__ == 0 on 2.6?

6. endlightenment & Gnome desktop Shortcut name

7. why isn't __STDC__ being defined?

8. Memory Leak in File Locking?

9. It's not bad canned meat...

10. Canned Proxy URLs to Filter

11. CGI: apache canned response

12. For those of you tired of canned distributions...