문제

We are porting a Linux driver to Windows. In Linux global structures are initialized in the following way.Assuming the structure has 4 elements where only 3 are initialized.

struct globalInitialize init = {
     .a = 10,
     .b = 20,
     .d = 30,
};

This is fine with Linux, but when directly used in WINDOWS we get compilation errors and it should be modified as below

struct globalInitialize init = {
     10,
     20,
     NULL,
     30,
};

Is there any way to suppress these compilation errors in windows without any changes to code. Let me know for more details.Thanks in advance.

도움이 되었습니까?

해결책

I don't know if it is obligatory for your development team to use the Visual C++ compiler from Microsoft, but there are gcc ports available for Windows. An example of such port is MinGW, or if you want an entire POSIX application deployment platform you could look at Cygwin.

If you have to use Visual C++ , you should update to/buy the right version supporting these 'new' 'C11' features (thanks Nigel Harper).

Supports ISO C11 language features including _Bool, compound literals, designated initializers, and mixing declarations with code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top