• 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:16:52 -0400

On 28-Apr-06, at 11:24 AM, Chris Espinosa wrote:

On Apr 28, 2006, at 4:33 AM, Peter Lau wrote:

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

struct A {
   int     a;
  float   b;
  char    c;
};

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

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

Try the "C Language Dialect" build setting. If you want just this .cp file to be C99, you can set its File Type in Get Info to sourcecode.c instead of sourcecode.cpp.cpp. You may also need to set the file's per-file flags (in the Build tab) to -std=c99

doing so the compiler will flag the C++ contents like #include <iostream> or using namespace std.


I was hoping it will understand it by set up the compiler as "-ObjC+ +" but still no good.

What I need is a compiler to accept both C++ and C99 syntax.

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


References: 
 >named initialization of structs in a .cpp file (From: Peter Lau <email@hidden>)
 >Re: named initialization of structs in a .cpp file (From: Chris Espinosa <email@hidden>)

  • Prev by Date: Re: named initialization of structs in a .cpp file
  • Next by Date: ranlib
  • Previous by thread: Re: named initialization of structs in a .cpp file
  • Next by thread: Re: named initialization of structs in a .cpp file
  • Index(es):
    • Date
    • Thread