Book a Demo

Author Topic: packed qualifier in c++ struct  (Read 3327 times)

wink

  • EA User
  • **
  • Posts: 48
  • Karma: +0/-0
  • Montjoie, que jamais ne choit!
    • View Profile
packed qualifier in c++ struct
« on: November 30, 2005, 01:05:51 am »
Hello everybody,

Developing embedded C++ applications I need to control the structure alignment with a the "packed" qualifier like this:

Code: [Select]
packed  struct MyStruct
{
   float AFloat;
   int AnInteger;
};


When I try to reverse this code, I get a parsing error.
I tried to declare a preprocessor macro "packed" but it doesn't help either.
This is funny beause if I put a stock macro like "PASCAL" instead of "packed" the parser accepts it.

This works:
Code: [Select]
PASCAL struct MyStruct
{
   float AFloat;
   int AnInteger;
};


I'd greatly appreciate any help!
Many thanks in advance,

cheers,
Manfred
Best regards,
Manfred

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: packed qualifier in c++ struct
« Reply #1 on: November 30, 2005, 01:24:54 am »
Since 'packed' is not a standard C (or C++) keyword, I can see why you would get a parsing error, just as if you put in 'platypus'.

I can't see why it got rejected if you had killed it as an EA macro.
It should have been invisible.

See here: http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=general;action=display;num=1103110378

It's possible that PASCAL is already eliminated by a similar macro definition somewhere - that works !
« Last Edit: November 30, 2005, 02:14:22 am by mikewhit »

wink

  • EA User
  • **
  • Posts: 48
  • Karma: +0/-0
  • Montjoie, que jamais ne choit!
    • View Profile
Re: packed qualifier in c++ struct
« Reply #2 on: November 30, 2005, 01:46:38 am »
Hi Mike,

I totally agree with you, but unfortunately it doesn't work!  :'(

It is like if only the stock macros would be recognized by the parser.
Best regards,
Manfred

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: packed qualifier in c++ struct
« Reply #3 on: December 01, 2005, 01:43:29 pm »
Hi guys,

I can confirm two things.

PASCAL is a macro with built-in support.

Adding packed as a macro should work, but instead reveals a bug that should be fixed for the next build.

wink

  • EA User
  • **
  • Posts: 48
  • Karma: +0/-0
  • Montjoie, que jamais ne choit!
    • View Profile
Re: packed qualifier in c++ struct
« Reply #4 on: December 01, 2005, 11:49:42 pm »
Hi Simon,

thanks for the information!
Great to hear that this issue will be addressed in the next build.

keep up the good work,
cheers Manfred
Best regards,
Manfred