• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Namespace problem with gcc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Namespace problem with gcc


  • Subject: Namespace problem with gcc
  • From: Michael Gaines <email@hidden>
  • Date: Fri, 22 Jun 2007 08:48:04 -0700

Hi everyone,
  I came across this problem when trying to compile some code that works in Visual Studio but not Xcode/gcc. Apparently, from what I read, this SHOULD be valid in C++ but gcc doesn't seem to like it. Here's a sample:

#include <stdio.h>

typedef enum _Type {
  HEY, JUDE
} Type;

typedef struct _object {
  int object_number;
  int generation_number;
  Type Type;
}object;

main()
{
	printf("Hello, world!\n");
}

If I save the file as "main.cpp" and compiled for C++, I get:

	main.cpp:10: error: declaration of 'Type _object::Type'
	main.cpp:5: error: changes meaning of 'Type' from 'typedef enum _Type Type'

If I save the file as "main.c", it builds fine.

Doing some research I found that C has different namespaces for types and variables, but C++ didn't originally. The book I found this in said that it should have been incorporated into C++ but I think gcc doesn't have this fix. So, the question is, how can I fix it? I can't find anything in the Xcode or gcc docs to solve this problem, short of changing the names of the types (why someone did it like this to begin with I don't know). Thanks.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Namespace problem with gcc
      • From: Adin Hunter Baber <email@hidden>
  • Prev by Date: Re: Protected m4p file prevents debug
  • Next by Date: Re: Crash report doesn't list function names?
  • Previous by thread: Re: Protected m4p file prevents debug
  • Next by thread: Re: Namespace problem with gcc
  • Index(es):
    • Date
    • Thread