Does the realview arm compiler support the following syntax:
#pragma pack(push, 1) and #pragma pack(pop)
or do I need to separate it into
#pragma push #pragma pack(1) and #pragma pop
There are no compiler warnings given for the former, but I'm having some issues with unaligned memory accesses on some ported code.
Also what happens when you do
#pragma pack()
with no parameter, will it revert to the default (8)?
www.keil.com/.../armccref_CJAFEEDG.htm
Thank you for the reply.
I had already read that page, but still had questions.
#pragma push (pop, 1) does not give any errors in Keil, but it's not clear whether it actually works or not.
It's not clear (to me, at least) what you mean by "it" there:
- the packing?
- the pushing?
- the popping?
- other?
or some combination of the above?
by "it" i meant "pragma pack (push,1)", as referred to earlier in the sentence.
There's nothing in the documentation which says that particular syntax is supported.
It does appear to work (at least, there are no compilation errors), but I've unfolded all the #pragmas into separate push and pack, just in case.
I believe "#pragma" is never supposed to give an error. If a tool does not support the #pragma, it is supposed to be ignored (without error or warning). I believe the the compiler is just properly ignoring the given unsupported "#pragma".
"I believe "#pragma" is never supposed to give an error."
Not certain whether it should or it shouldn't, but just this morning while porting some code originally written using (an older) Microsoft C compiler with MDK 4.11 I got.
warning: #161-D: unrecognized #pragma
This was for a line in the code:
#pragma page()
Yes, I'm sure I've seen that kind of thing in such situations from various compilers
Yes, my mistake on the warnings. They are ALLOWED to give warnings (but not required). They are not allowed to give an error.
The point was, that if the manual does not say that it supports a #pragma or #pragma feature, there is no easy way to be sure if it is supported (i.e. messages from the compiler may or may not give a clue). I believe in this case the compiler does support the #pragma pack (and this is why it does not give a warning), but not not support it in the way the OP is hoping (the compiler is silent about not supporting it the way the OP wants).
Yes, the compiler supports #pragma pack (n), but it does not seem to support #pragma (push/pop, n) as in Visual Studio.
No errors/warnings are given when you use the unsupported syntax, which was the reason for my original question.
View all questions in Keil forum