Pelles C forum

C language => Expert questions => Topic started by: czerny on May 08, 2012, 01:08:49 PM

Title: ISO TR24731-1
Post by: czerny on May 08, 2012, 01:08:49 PM
If I try to compile this


#include <stdio.h>
#include <stdarg.h>

int main(void)
{
char s[20];

vsprintf_s(s,20,"","");

return 0;
}


I get the following error


tst6\main.c(9): warning #2018: Undeclared function 'vsprintf_s'; assuming 'extern' returning 'int'.


I always remember, that I have to #define something to allow this function. But always I search half a hour or even longer the help file until I finally find the right hint.


#define __STDC_WANT_LIB_EXT1__ 1


Today I have noticed that vsprintf_s is marked with [TR24731-1] in its help head. So hopefully I get it quicker next time.

But I too read that this is a C11 function now.

Shouldn't it be available now without any defines if C11 is enabled?

czerny
Title: Re: ISO TR24731-1
Post by: iZzz32 on May 08, 2012, 03:26:30 PM
Quote from: ISO/IEC 9899:2011, K.3.1.1 (3)It is implementation-defined whether the functions, macros, and types declared or defined in K.3 and its subclauses are declared or defined by their respective headers if __STDC_WANT_LIB_EXT1__ is not defined as a macro at the point in the source file where the appropriate header is first included.
Title: Re: ISO TR24731-1
Post by: Pelle on May 15, 2012, 04:29:03 PM
It's a optional extension of C11 and __STDC_LIB_EXT1_ _ is still there (in my late draft of the C1X standard)...