0

I think my new Windows machine cannot find the "attribute" mechanism. Is this because __attribute__ is a GNU thing only? I am trying to compile some headers that I created on my Linux box using gcc. I am using Visual C++ 6.0 for the first time in my life. How can I fix this?

Code:

typedef struct s_mystruct {
         unit somevar;
} __attribute__((packed)) MyStruct;

Error : error C2146: syntax error : missing ')' before identifier 'attribute' error C2061: "syntax error : identifier 'attribute' "

Same type of error at different place -->

**typedef unsigned long uint128_t __attribute__ ((mode(TI)));
                typedef long int128_t __attribute__ ((mode(TI)));**

This time even code is not enabled :(

Well, we can of course implement -

#define __attribute__(x)

which will simply remove the remark from the code during pre-processing.

But this solution may change build behavior.

Please suggest a better solution.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Nitin
  • 13
  • 4
  • https://stackoverflow.com/a/1545341/13912132 for __attribute__((packed)) – JCWasmx86 Aug 15 '20 at 11:35
  • For mode(TI), I think, there is no equivalent – JCWasmx86 Aug 15 '20 at 11:39
  • The `__attribute__` notation is a GCC extensiion, not standard C. If you're not using GCC, it won't necessarily work. As it happens, Clang also accepts the notation; for the most part, it is compatible with GCC. But Visual C++ is not GCC compatible. And Visual C++ 6.0 is archaic, isn't it? Wikipedia says [Visual C++ 6.0](https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History) was released in 1998. You should not be using it without an extraordinarily good reason. – Jonathan Leffler Aug 15 '20 at 13:41
  • If you're porting to Windows it's easier to stick with GCC by using MinGW-w64. A standalone compiler can be downloaded from: http://winlibs.com/ – Brecht Sanders Aug 17 '20 at 09:46

0 Answers0