Questions tagged [c99]

This tag is for questions regarding the International Standard ISO 9899:1999, aka "C99", with technical corrigenda, and for questions about code written in C99 (as opposed to K&R C, C89 or later C Standard revisions like the 2011 revision C11).

This tag is for questions regarding the International Standard ISO 9899:1999 , aka "C99", with technical corrigenda, and for questions about code written in C99 (as opposed to K&R C, C89 or later C Standard revisions like the 2011 revision C11).

Always use the tag for all your C questions, then complement it with the tags for questions that are specific to this version of the standard.

1900 questions
29
votes
3 answers

How to declare an inline function in C99 multi-file project?

I want to define an inline function in a project, compiled with c99. How can I do it? When I declare the function in a header file and give the detail in a .c file, the definition isn't recognized by other files. When I put the explicit function in…
mousomer
  • 2,632
  • 2
  • 24
  • 25
29
votes
2 answers

What does &(int) { 1 } mean in C++?

I saw this here and I don't know what it means: &(int) { 1 } I thought it was weird because it seems like invalid syntax. It's casting a block scope(?) with a random 1 in the middle (without a semi-colon) and taking the address. Doesn't make a lot…
Enu Ynu Ti
  • 241
  • 3
  • 7
28
votes
3 answers

Compiler support of GNU Statement Expression

Which modern compilers support the Gnu Statement expression (C and C++ languages). What versions should I have to use a statement expressions? Statement expression is smth like ({ code; code; retval }): int b=56; int c=({int a; a=sin(b); a;}); I…
osgx
  • 90,338
  • 53
  • 357
  • 513
28
votes
2 answers

What does GCC __attribute__((mode(XX)) actually do?

This arose from a question earlier today on the subject of bignum libraries and gcc specific hacks to the C language. Specifically, these two declarations were used: typedef unsigned int dword_t __attribute__((mode(DI))); On 32 bit systems…
user257111
28
votes
2 answers

Are all pointers derived from pointers to structure types the same?

The Question The question of whether all pointers derived from pointers to structure types are the same, is not easy to answer. I find it to be a significant question for the following two primary reasons. A. The lack of a pointer to pointer to…
Dror K.
  • 1,989
  • 17
  • 26
28
votes
4 answers

Is there a GCC keyword to allow structure-reordering?

I know why GCC doesn't re-order members of a structure by default, but I seldom write code that relies on the order of the structure, so is there some way I can flag my structures to be automaticly reordered?
Maestro
  • 9,046
  • 15
  • 83
  • 116
27
votes
3 answers

When to use restrict and when not to

I have a general understanding of restrict but I'm hoping to clarify some fine points. I have a function that reads a null-terminated string from one buffer and writes out a URL encoded version in another buffer. The function has this signature…
Don McCaughey
  • 9,532
  • 3
  • 30
  • 36
27
votes
4 answers

Good introduction to

I want to recommend the use of to someone doing printf with mixed 32/64 bit builds. I tried to Google an introduction or tutorial page with a few examples and usage guidelines, but I couldn't find one. Can someone recommend an…
Ben Jackson
  • 90,079
  • 9
  • 98
  • 150
27
votes
3 answers

Is this a clang optimizer bug or an undefined behavior in C?

This code gives different results for -O1 and -O2: /* Example of a clang optimization bug. Mark Adler, August 8, 2015. Using -O0 or -O1 takes a little while and gives the correct result: 47 bits set (4294967296 loops) …
Mark Adler
  • 101,978
  • 13
  • 118
  • 158
26
votes
6 answers

How to tell GCC that a pointer argument is always double-word-aligned?

In my program I have a function that does a simple vector addition c[0:15] = a[0:15] + b[0:15]. The function prototype is: void vecadd(float * restrict a, float * restrict b, float * restrict c); On our 32-bit embedded architecture there is a…
ysap
  • 7,723
  • 7
  • 59
  • 122
26
votes
1 answer

Is stdout line buffered, unbuffered or indeterminate by default?

Section 7.19.3/7 of c99 states that: At program start-up, three text streams are predefined and need not be opened explicitly - standard input (for reading conventional input), standard output (for writing conventional output), and standard error…
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
26
votes
3 answers

Is int main() { } (without "void") valid and portable in ISO C?

The C standard specifies two forms of definition for main for a hosted implementation: int main(void) { /* ... */ } and int main(int argc, char *argv[]) { /* ... */ } It may be defined in ways that are "equivalent" to the above (for example, you…
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
25
votes
5 answers

Why is the syntax "int (*)[*]" necessary in C?

Just was looking something up in the ISO/IEC9899 When I stumbled on this: 6.7.6 Type names [...] Semantics 2 In several contexts, it is necessary to specify a type. This is accomplished using a type name, which is syntactically a declaration…
dhein
  • 6,431
  • 4
  • 42
  • 74
25
votes
2 answers

How to compile for a freestanding environment with GCC?

The code I'm working on is supposed to be possible to build for both hosted and freestanding environments, providing private implementations for some stdlib functions for the latter case. Can I reliably test this with just GCC on a normal…
Christoffer
  • 12,712
  • 7
  • 37
  • 53
24
votes
4 answers

Is there a meaningful distinction between freestanding and hosted implementations?

The question I have is mostly related to section four, paragraph six. The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any strictly conforming program. As I understand, this…
autistic
  • 1
  • 3
  • 35
  • 80