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 7962065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:13:39+00:00 2026-06-04T05:13:39+00:00

GCC tells me you can’t use the same names for separate enumerated type values,

  • 0

GCC tells me you can’t use the same names for separate enumerated type values, e.g.

enum flag_one {
    SUCCESS,
    FAIL
}

enum flag_two {
    SUCCESS,
    FAIL
}

is not allowed by the compiler. So scoping is not ‘witihin’ the enum definition?

Is the approach to do something like:

enum flag_one {
    FLAG_ONE_SUCCESS,
    FLAG_ONE_FAIL
}

enum flag_two {
    FLAG_TWO_SUCCESS,
    FLAG_TWO_FAIL
}

Slightly confused as I like using enums for return integer codes as its more readable/descriptive but I’m already starting to get name clashes

  • 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-06-04T05:13:41+00:00Added an answer on June 4, 2026 at 5:13 am

    So scoping is not ‘witihin’ the enum definition?

    No. This is not allowed. Enumerator lists define constants. Your enums happen to be in the same scope — the file scope. You cannot have two constants with the same name within the same scope.

    From the draft of CX:

    6.7.2.2 Enumeration specifiers

    Semantics

    3 The identifiers in an enumerator list are declared as constants that have type int and
    may appear wherever such are permitted.127) […]

    Also, from footnote 127 (which is technically non-normative and for informational purposes only):

    127) Thus, the identifiers of enumeration constants declared in the same scope shall all be distinct from
    each other and from other identifiers declared in ordinary declarators.

    .

    Slightly confused as I like using enums for return integer codes […]

    Use EXIT_SUCCESS and EXIT_FAILURE defined in stdlib.h.

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

Sidebar

Related Questions

gcc 4.1.2 c99 I have the following enum's in this file ccsmd.h : enum
gcc 4.4.2 c89 I have the following enum: enum drop_options_e { drop_ssm, drop_snm, drop_ssb
According to the GCC documentation , __attribute__((pure)) tells the compiler that a function has
Basic Question : How can I get gcc to tell me where it searches
I'm trying to build pysox (module to use SoX in Python). But mingw32-gcc show
GCC is a very well respected multi-language compiler (from what I've gathered). One thing
gcc I am just getting back into c programming and I am just practicing
GCC's recent support for atomic operations (as described here ) is great, and is
gcc 4.4.2 c89 I have a wave file: 8000 Hz 16 bit I am
gcc 4.4.2 I have the following code: char channels[] = NumberOfChannel = [2]; sscanf(channels,

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.