This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Why not have a standard macro for this?
#define STR_STRLEN_PAIR(STR) \ STR, (sizeof (STR) - 1)
Just a thought, I am not suggesting to go all over the code base to adapt to something like this, but we could make new code use something like this.
Code improvements that remove the potential for bugs are always welcome. In this particular case you could always make the macro slightly more intelligent, so that it could handle the NULL pointer, eg:
#define STR_STRLEN_PAIR(STR) \ (STR), (STR) ? sizeof (STR) - 1 : 0
#define STR_STRLEN_PAIR(STR) \ (STR), (STR)==0 ? sizeof (STR) - 1 : 0
But that errors out on gcc 3.4 with: main.c:15: error: initializer element is not constant so I discarded that form :)
Cheers, Pedro Alves
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |