c - Macro error in C99 and MS Visual Studio 2015 -


we have problems compiling our gcc c99 code msvs 2015. problematic line seems macro expansion, problem occurs in line:

const ua_qualifiedname datename = ua_qualifiedname(1, "current time"); 

the error

intellisense value of type âua_stringâ cannot used initialize entity of type âua_int32â.

where macros follows:

#define ua_qualifiedname(ns_index, chars) (const ua_qualifiedname) { \                         .namespaceindex = ns_index, .name = ua_string(chars) } #define ua_string(chars) (ua_string) {strlen(chars), (ua_byte*)chars } 

and structs are

typedef struct {     ua_int32 length;     ua_byte *data; } ua_string; 

as

typedef struct {     ua_uint16 namespaceindex;     ua_string name; } ua_qualifiedname;     

it valid c code far can see it. have idea how can workaround msvs?

p.s.: apparently seems cast ua_string in second macro. however, removing breaks code gcc , clang

c99 introduced support feature known compound literals, manifests cast ua_string in second macro. isn't cast. it's initialisation, , use of anonymous object. you're right, though... it's been valid c, @ least fifteen years now.

unfortunately, have realised hard way, msvs doesn't support c99. that's right, there's valid, portable , compliant c code written fifteen years ago , won't compile using msvs.

microsoft claims support in documentation (as have introduced c99ish functions). haven't introduced of core language additions, such compound literals, however. in fact, parts of library broken in fundamental ways; printf , scanf need serious updates. msvs hates c programmers :(

you might have success compiling c99 code in msvs getting started llvm system using microsoft visual studio...

alternatively, if must use microsoft's compiler in spite of lack of care code, fix simple enough... don't use compound literals.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -