How to enable __attribute__ support

How to enable __attribute__ support

Hi Folks,

7.1 compiler release notes (windows version)
seem to imply that __attribute__ keyword is supported. But I get bunch of errors when I try to compile code
that uses it.

test.c(20): error: expected a type specifier
} __atribute__ ((packed));
^
test.c(29): error: expected a type specifier
} __atribute__ ((aligned(4)));
^
Does anybody know how to enable it ?

Thanks

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Recheck your spelling of attribute in the testcase.

If that doesn't do it, can you post your sample testcase here.

Thanks,

Max

Actually I cut&pasted wrong output. I fixed the spelling
but it didn't work either (same error).

Here is complete source:

----
#include

#define STR(x) #x
#define STR2(x) STR(x)

#define DEBUG(...)
do {
printf("DEBUG: " __FILE__ ":" STR(__LINE__) " " __VA_ARGS__);
} while(0)

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

struct s {
uint8_t u8;
uint16_t u16;
} __attribute__ ((packed));

int main(void)
{
DEBUG("test");

DEBUG("sizeof %d", sizeof(struct s));
}
----

test.c(19): error: expected a type specifier
} __attribute__ ((packed));
^

Basically I need two things that VC++ doesn't support.
Macros with variable arguments and some way to pack/align structs without those ugly #pragma things.

So macros seem to work if /Qc99 option is enabled. I guess
there is some other option to enable __attribute__ stuff.

Thanks

Maxk,

Can you point me to the portion of the release notes where we claim that __attribute__ is supported by our Windows compiler? __attribute__ support was added for gcc compatibility. If the release notes imply that they are supported under Windows, I'd posit the problem is in the release notes.
This may not help you, I know, but I'd like to understand why you'd consider this feature important on Windows. Details on porting???

Thanks,

Max

I don't find it surprising that people look to the Intel compiler for compatibility with gcc, even though gcc isn't a dominant compiler on Windows. The expectation certainly would be more reasonable if it didn't involve gcc extensions. It can be disappointing when gcc out-performs the Intel compiler on Windows, and the only solution is to use more non-portable extensions and configuration dependencies. At least gcc supports the same extensions on all OS targeting the same hardware.

Leave a Comment

Please sign in to add a comment. Not a member? Join today