Is there a difference if I compile the following program using c89 vs c99? I get the same output. Is there really a difference between the two?
#include <stdio.h>
int main ()
{
// Print string to screen.
printf ("Hello World\n");
}
gcc -o helloworld -std=c99 helloworld.c
vs
gcc -o helloworld -std=c89 hellowor...
Nearly every (relatively) new book about c programming I've seen doesn't seem to adhere to the C99 standard, or they cover it in an extra chapter. Comming from a Java background, the C99 standard made the migration (well, still migrating ^^) much easier for me, and this probably applies to other languages, too.
It seems like C99 hasn't ...
This code has an interesting bug:
some_struct struct_array1[10] = {0};
some_struct struct_array2[10] = {0}
int i;
for (i = 0;
i < sizeof(struct_array1) / sizeof(struct_array1[0]);
struct_array1[i].value = struct_array2[i++].value = 1)
;
For most compilers, the above code results in setting the "value" field of all str...
I last used C professionally around 1997 IIRC. I've used a lot of C++ since then. Now, I find I need to use some C again.
One thing I'm sure of is that I can't just drop the obvious C++ features (e.g. classes) and expect everything to work. There are various less obvious syntax changes. I just don't remember what they are.
Is there a g...
Is there currently a group working on the next C standard (by next, I mean after C99)? If so, what are the features likely to make it in?
...
I realise you can just #define some integers, but why didn't C have a dedicated boolean data type before C99?
It's such a common occurence in programming and logic, I don't understand the absense of an explicit type and notation.
...
I maintain several modest-sized C programs, and I frequently have a use for fully accurate cross-reference information. Unlike "tags" or other approximations, such information is typically generated by a compiler that knows the full scoping rules of the C language and can provide accurate information accordingly. For example, here is a...
Hi,
I'm writing an app in pure C which expects two line at input:
first one, which tells how big an array of int will be,
and the second, which contains values, separated by space.
So, for the following input
5
1 2 3 4 99
I need to create an array containing {1,2,3,4,99}
Now, my question is - what is the fastest (yet easy ;)) way to do ...
EDIT: I had made a mistake during the debugging session that lead me to ask this question. The differences I was seeing were in fact in printing a double and in parsing a double (strtod). Stephen's answer still covers my question very well even after this rectification, so I think I will leave the question alone in case it is useful to s...
Code:
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
int main() {
typeof(5);
return 0;
}
Version of gcc is 4.3.3, command line is "gcc.exe -std=c99 1.c -o 1.exe".
What is the cause of this problem?
...
Hi, I was looking at new features of C99 and saw the floating point environment:
#include <fenv.h>
My question is simple. If I'm performing floating point number computations, do I have to include the above preprocessor directive in my code? If no, then what does this directive do and when does it become important to include?
Thanks ...
When reading some FreeBSD source code (See: radix.h lines 158-173), I found variable declarations that followed the "function heading" in the definition.
Is this valid in ISO C (C99)? when should this be done in production code instead of just declaring the variables within the "function heading?" Why is it being done here?
I refer to...
Hello
What is maximal bit width for bit struct field?
struct i { long long i:127;}
Can I define a bif field of size 128, 256 bit or larger? There are some extra-width vector types, like sse2, avx registers.
...
Hi, I just read that C99 has double_t which should be at least as wide as double. Does this imply that it gives more precision digits after the decimal place? More than the usual 15 digits for double?.
Secondly, how to use it: Is only including
#include <float.h>
enough? I read that one has to set the FLT_EVAL_METHOD to 2 for long ...
Hi, I read with interest the post "How universally is C99 supported ?". One of the comments therein points that Microsoft doesn't support C99. But the comment symbol // works with VS 2008 and this symbol is in C99. I have two questions:
To what extent VS 2008 support C99?
Is it ok in the same code to mix C89 and C99 syntax together? So...
How come the Linux kernel can compile only with GCC? What GNU C extensions are really necessary for some projects and why?
...
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 workstation/build server?
The "-ffreestanding" option looked promising, but it seems that it "on...
Hello
In good Altix manual (altix_single_cpu_optimization) I've found this list of pragmas-hints for optimizing compilers
#pragma ivdep // no aliasing
#pragma swp // try to software-pipeline
#pragma noswp // disable software-pipelining
#pragma loop count (NN) // hint for SWP
#pragma distr...
I am looking for a free static checker for C99 code (including GCC extensions) with the ability to explicitly say "these preprocessor macros are always defined."
I need that last part because I am compiling embedded code for a single target processor. The compiler (Microchip's C32, GCC based) sets a macro based on the selected processo...
I would like to have a string (char*) parsed into a tm struct in C. Is there any built-in function to do that?
I am referring to ANSI C in C99 Standard.
...