Questions tagged [gcc-attribute]
7 questions
3
votes
2 answers
What preprocessor condition should I check so as to use __attribute__((const))?
I've gotten a piece of code which applies __attribute__((const)) to some functions. Now, I'd rather not remove it when it's usable, but on the other hand, I do want to be more portable, so - I want to say
#if some condition here
#define…

einpoklum
- 118,144
- 57
- 340
- 684
1
vote
0 answers
What does "mode" attribute do?
I have read the documentation but I am not able to understand it. What does following typedefs do? What is/should be size of a variable of type word/pointer/_Unwind_Word on a 8/16/32/64 bit architecture?
typedef unsigned int word…

jdx
- 130
- 6
1
vote
2 answers
__attribute__ in definitions of multiple variables
I have a question which is best explained by example. Please consider the following code:
unsigned char a,
b;
This obviously defines two variables of type unsigned char.
If I would like to make the variables aligned to…

Binarus
- 4,005
- 3
- 25
- 41
1
vote
1 answer
How can I create a platform-independent macro to wrap a compiler extension?
I have some code like this that I need to make cross-platform:
int __attribute__((noinline)) fn() { return 0; }
I want to use Waf to write a config.h that contains
#define ATTRIBUTE(attr) __attribute__((attr))
if the compiler supports this…
user2201041
0
votes
0 answers
why weak attribute has not been selected for C23?
I can see that there is a new keyword type 'attributes' in C23.
Some of it, like [[deprecated]] were used in C11+GNU __attribute__((deprecated)).
I looks like a great update.
I wonder why a usefull keyword as __attribute__((weak)) is not part of the…

Guillaume D
- 2,202
- 2
- 10
- 37
0
votes
1 answer
GCC attribute __attribute__ ((constructor)) from main executable runs after linked libraries constructors
I noticed that constructors from shared objects linked into my applications will always run before my application constructors, even if my applications has lower priority number (ie: higher priority); for example, let's say this program:
#include…

Federico
- 221
- 3
- 11
0
votes
1 answer
Is a C struct of all-packed fields except first one different from packed struct?
Among its Common Type Attributes, GCC provides packed:
This attribute, attached to a struct [...] type
definition, specifies that each of its members (other than zero-width
bit-fields) is placed to minimize the memory required. This is
equivalent…

PiCTo
- 924
- 1
- 11
- 23