Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7005185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:19:10+00:00 2026-05-27T21:19:10+00:00

Today I stumbled upon a rather interesting compiler error: int main() { int const

  • 0

Today I stumbled upon a rather interesting compiler error:

int main() {
  int const unix = 0; // error-line
  return unix;
}

Gives the following message with gcc 4.3.2 (yes, ancient…):

error: expected unqualified-id before numeric constant

which is definitely quite confusing.

Fortunately, clang (3.0) is a little more helpful (as usual):

error: expected unqualified-id
  int const unix = 0
            ^
<built-in>:127:14: note: expanded from:
#define unix 1
             ^

I certainly did not expect unix, which is neither written in upper-case nor begin with underscore to be a macro, especially a built-in one.

I checked the predefined macros in gcc and there are 2 (on my platform) that use “unreserved” symbols:

$ g++ -E -dM - < /dev/null | grep -v _
#define unix 1
#define linux 1

All the others are “well-behaved” macros with leading underscores, using the traditional reserved identifiers, sample:

#define __linux 1
#define __linux__ 1
#define __gnu_linux__ 1

#define __unix__ 1
#define __unix 1

#define __CHAR_BIT__ 8
#define __x86_64 1
#define __amd64 1
#define _LP64 1

(it’s a mess and there does not seem to be any particular order…)

Furthermore, there are lots of “similar” symbols, so I guess there is an issue of backward compatibility…

So, where do the unix and linux macros come from ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:19:10+00:00Added an answer on May 27, 2026 at 9:19 pm

    gcc does not fully conform to any C standard by default.

    Invoke it with -ansi, -std=c99, or -std=c1x and unix won’t be predefined. (-std=c1x will probably become became -std=c11 in a future more recent gcc release.)

    It’s a bit confusing that this is documented in the separate manual for the GNU preprocessor, not in the gcc manual.

    Quoting the GNU preprocessor documentation (info cpp, version 4.5):

    The C standard requires that all system-specific macros be part of
    the “reserved namespace”. All names which begin with two underscores,
    or an underscore and a capital letter, are reserved for the compiler
    and library to use as they wish. However, historically
    system-specific macros have had names with no special prefix; for
    instance, it is common to find `unix’ defined on Unix systems. For
    all such macros, GCC provides a parallel macro with two underscores
    added at the beginning and the end. If `unix’ is defined,
    `__unix__’ will be defined too. There will never be more than two
    underscores; the parallel of `_mips’ is `__mips__’.

    When the `-ansi’ option, or any `-std’ option that requests strict
    conformance, is given to the compiler, all the system-specific
    predefined macros outside the reserved namespace are suppressed. The
    parallel macros, inside the reserved namespace, remain defined.

    We are slowly phasing out all predefined macros which are outside the
    reserved namespace. You should never use them in new programs, and we
    encourage you to correct older code to use the parallel macros
    whenever you find it. We don’t recommend you use the system-specific
    macros that are in the reserved namespace, either. It is better in
    the long run to check specifically for features you need, using a tool
    such as `autoconf’.

    The current version of the manual is here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've stumbled upon a rather strange issue today with Spring 3.0: There's an abstract
Today I stumbled upon an interesting bug I wrote. I have a set of
today I stumbled upon a very interesting case (at least for me). I am
Today I stumbled upon the possibility to access a DOM element in Javascript simply
I stumbled on an interesting issue today. In the context of a single file
I just today stumbled upon the Code Metrics thing, after having used Visual Studio
Today, I've stumbled over the following: Consider two classes NewClass and NewClass1, which have
In a code review today, I stumbled across the following bit of code (slightly
Today I stumbled upon a case where I would readily assume a simple optimization
I stumbled upon this oddity today while playing with some code to go down

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.