c99

C99 stdint.h header and MS Visual Studio

To my amazement I just discovered that the C99 stdint.h is missing from MS Visual Studio 2003 upwards. I'm sure they have their reasons, but does anyone know where I can download a copy? Without this header I have no definitions for useful types such as uint32_t, etc. ...

How universally is C99 supported ?

How universally is the C99 standard supported in today's compilers ? I understand that not even GCC fully supports it. Is this right ? Which features of C99 are supported more than others, i.e. which can I use to be quite sure that most compilers will understand me ? Thanks ...

Visual Studio support for new C / C++ standards?

Hello everyone, I keep reading about C99 and C++0x and all these totally sweet things that are getting added to the language standard that might be nice to use someday. However, we currently languish in the land of writing C++ in Visual Studio. Will any of the new stuff in the standard ever get added to visual studio, or are microsoft ...

Why are there digraphs in C and C++?

I learned today that there are digraphs in C99 and C++. The following is a valid program: %:include <stdio.h> %:ifndef BUFSIZE %:define BUFSIZE 512 %:endif void copy(char d<::>, const char s<::>, int len) <% while (len-- >= 0) <% d<:len:> = s<:len:>; %> %> My question is: why do they exist? ...

Are prototypes required for all functions in C89, C90 or C99?

To be truly standards-compliant, must all functions in C (except for main) have a prototype, even if they are only used after their definition in the same translation unit? ...

How to portably convert a string into an uncommon integer type?

Some background: If I wanted to use for, for instance, scanf() to convert a string into a standard integer type, like uint16_t, I’d use SCNu16 from <inttypes.h>, like this: #include <stdio.h> #include <inttypes.h> uint16_t x; char *xs = "17"; sscanf(xs, "%" SCNu16, &x); But a more uncommon integer type like pid_t does not have any suc...

What is the differences about struct in C99 to ANSI-C ?

Hello, This code doesn't appear to be correct in ANSI-C, but ok in C99 : struct a { int x; int y; } z; What are the differences about struct in C99 and ANSI-C ? Edit: I forgot the "a", my bad. This code compiles ok with gcc in C99 mode, but is a parse error on splint, which is known to not support all the C99 extensions. Edit2: here...

Why can't gcc find the random() interface when -std=c99 is set?

I do "#include <stdlib.h>" at the top of the source. Example compilation: /usr/bin/colorgcc -std=c99 -fgnu89-inline -g -Wall -I/usr/include -I./ -I../ -I../../ -I../../../ -I../../../../ -O3 -o f8 f8.c In file included from f8.c:7: ctype-cmp.c: In function ‘randomized’: ctype-cmp.c:48: warning: implicit declaration of function ‘ra...

References for libSystem library

According to the documentation, iPhone's core OS includes the libSystem library, which I assume contains the standard C library functions and probably more. How can I find out about all the functions that are available in libSystem? ...

How can I make splint ignore where I declare my variables?

Hi Do you know how can I make splint ignore where I declare my variables? I know that the old school c tells you to declare variables right at the beginning in every function, but since I am a bad person I like to declare things close to where I use them. A good example is to put int i; right before the for(i=0;...). Let's take a v...

question about incompatible printf format specifiers

I was just looking through the man page for printf and something occurred to me. I was wondering if there are any "language lawyers" here which could answer a relatively simple question :-P. So the 't' modifier is defined as A following integer conversion corresponds to a ptrdiff_t argument. So what is supposed to happen if you...

Is "The C Programming Language" (book) current?

Is the version of C taught by this rather old, but frequently mentioned, book the same as that which is being used in the real world today? If not, could anyone list or point to a list of the differences? ...

Realistic usage of the C99 'restrict' keyword?

I was browsing through some documentation and questions/answers and saw it mentioned. I read a brief description, stating that it would be basically a promise from the programmer that the pointer won't be used to point somewhere else. Can anyone offer some realistic cases where its worth actually using this? ...

ASM in C gives an error with -std=c99

I'm now willing to compile my project with -std=c99 and I'm facing an error I'm not understanding for the moment. This line : my_type* td = ({ register kmy_type* arg0 asm("eax"); arg0; }); gives me the following error only in C99 : warning: ISO C forbids nested functions error: syntax error before ‘asm’ error: ‘arg0’ undeclared (firs...

Smart pointers/safe memory management for C?

Hi, I, and I think many others, have had great success using smart pointers to wrap up unsafe memory operations in C++, using things like RAII, et cetera. However, wrapping memory management is easier to implement when you have destructors, classes, operator overloading, et cetera. For someone writing in raw C99, where could you point ...

Is there a Perl module to convert c99 hex floating point notation to regular notation?

Is there a built-in library that I can use to convert c99 style floating point notation, example: 0x1.0p23f, to regular floating point numbers using Perl (and vice versa)? Thanks, ...

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 (currently without restrict): char const *StringUrlEncode(char const *unencoded, ...

Where can I find an implementation of C99's math for Visual Studio?

I have some code that uses several math functions that exist in C99, but aren't defined in math.h or cmath that come with VS2005. Anywhere I can get a VS2005 compatible implementation of C99? ...

restrict-edness with pre-c99

Considering this code, VC9 doesn't detect aliasing : typedef struct { int x, y; } vec_t; void rotate_cw(vec_t const *from, vec_t *to) { /* Notice x depends on y and vice versa */ to->x = from->y; to->y = -from->x; } /* ... */ vec_t a, b; rotate_cw(&a, &b); /* OK, no aliasing */ rotate_cw(&a...

Why can't I assign a const value, and what should I do instead?

I have a piece of code with the following rough signature: void evaluate(object * this) { static const int briefList[] = { CONSTANT_A, CONSTANT_Z }; static const int fullList[] = { CONSTANT_A, CONSTANT_B, ..., CONSTANT_Z}; const int const * pArray; const int nElements; int i; if ( this->needDeepsEvaluation ) ...