Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #15836

Re: Compile error

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c
Subject Re: Compile error
Date 2012-01-15 23:28 +0000
Organization A noiseless patient Spider
Message-ID <20120115151900.469@kylheku.com> (permalink)
References <5976423f-f7d5-40e6-b8fa-7636c8a8d8b7@a17g2000yqj.googlegroups.com> <lnsjjg1vhv.fsf@nuthaus.mib.org>

Show all headers | View raw


On 2012-01-15, Keith Thompson <kst-u@mib.org> wrote:
> dspfun <dspfun@hotmail.com> writes:
>> I get a compile/preprocessor error when trying to call/use the
>> following line:
>> openlog (__FUNCTION__, 0x02 | 0x01 | 0x08, (1<<3));
>>
>>
>> The openlog function is declared as:
>>
>> extern void openlog (__const char *__ident, int __option, int
>> __facility);
>
> Is "__const" a macro for "const"?  If so, why not just use "const"?

Yes and no. GCC has such a keyword.

In the GNU C Library /usr/include/sys/cdefs.h we have this:

#ifdef __GNUC__

/* GCC can always grok prototypes.  For C++ programs we add throw()
   to help it optimize the function calls.  But this works only with
   gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions
   as non-throwing using a function attribute since programs can use
   the -fexceptions options for C code as well.  */
# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
#  define __THROW	__attribute__ ((__nothrow__))
#  define __NTH(fct)	__attribute__ ((__nothrow__)) fct
# else
#  if defined __cplusplus && __GNUC_PREREQ (2,8)
#   define __THROW	throw ()
#   define __NTH(fct)	fct throw ()
#  else
#   define __THROW
#   define __NTH(fct)	fct
#  endif
# endif

#else	/* Not GCC.  */

# define __inline		/* No inline functions.  */

# define __THROW
# define __NTH(fct)	fct

# define __const	const
# define __signed	signed
# define __volatile	volatile

#endif	/* GCC.  */

> If it's to cater to compilers that don't support "const", I hardly think
> that's necessary these days.

It avoids unnecessary namespace pollution, I suppose. A program can use
const as a macro and it won't interfere with the GNU C Library headers.

*shrug*

Good questions for the glibc mailing list.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Compile error dspfun <dspfun@hotmail.com> - 2012-01-15 08:14 -0800
  Re: Compile error NEON China BLUE <chine.bleu@yahoo.com> - 2012-01-15 08:29 -0800
    Re: Compile error dspfun <dspfun@hotmail.com> - 2012-01-15 08:32 -0800
      Re: Compile error dspfun <dspfun@hotmail.com> - 2012-01-15 09:07 -0800
  Re: Compile error "BartC" <bc@freeuk.com> - 2012-01-15 17:13 +0000
  Re: Compile error Keith Thompson <kst-u@mib.org> - 2012-01-15 13:55 -0800
    Re: Compile error Ian Collins <ian-news@hotmail.com> - 2012-01-16 11:25 +1300
    Re: Compile error Kaz Kylheku <kaz@kylheku.com> - 2012-01-15 23:28 +0000
    Re: Compile error Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-01-16 12:37 +0000
      Re: Compile error Keith Thompson <kst-u@mib.org> - 2012-01-16 12:02 -0800
        Re: Compile error blp@cs.stanford.edu (Ben Pfaff) - 2012-01-16 13:23 -0800
          Re: Compile error Keith Thompson <kst-u@mib.org> - 2012-01-16 14:17 -0800
            Re: Compile error dspfun <dspfun@hotmail.com> - 2012-01-17 03:40 -0800
        Re: Compile error Kaz Kylheku <kaz@kylheku.com> - 2012-01-16 21:51 +0000

csiph-web