• 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
Re: named initialization of structs in a .cpp file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: named initialization of structs in a .cpp file


  • Subject: Re: named initialization of structs in a .cpp file
  • From: Peter Lau <email@hidden>
  • Date: Fri, 28 Apr 2006 17:12:17 -0400

I have a .cpp file but I would like to use the C99 named
initialization for structs syntax, can I do that?

struct A sa = {.a = 1,.b = 2.3, .c = 'd'};

the compiler generates "expected primary-expression before '.' token.

I think you're expecting c99 features from the c++ compiler. This should
work with gcc, and fail with g++ as far as I can tell.

no, by default it tries to compile it as C++ ('cos the file extension is .cpp) so they really don't like the ".a = 1" syntax.


I tried to set the option "-std=c99" but it does not like the C++ contents like "#include <iostream>".

I guess what I need is a way to make the compiler to accept both C++ and C99. I have seen compiler options like that in the other compiler...

pete

_______________________________________________
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


  • Prev by Date: Specify multi-variant/arch output in custom build rule
  • Next by Date: Re: named initialization of structs in a .cpp file
  • Previous by thread: Re: named initialization of structs in a .cpp file
  • Next by thread: Editor weirdness
  • Index(es):
    • Date
    • Thread