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