Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Intel compiler 2019.5 cannot compile a .c file that includes <windows.h> (Visual Studio 2019 16.3.5)

AndrewC
New Contributor III
1,616 Views

Any attempt to compile a .c ( not .cxx) file that includes <windows.h> in a Visual Studio 2019 16.3.5 project using Intel 2019.5 results in the following error

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.23.28105\include\vcruntime_string.h(18): error : expected an attribute name
1>  _NODISCARD _Check_return_
1>  ^

 

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

void test()
{
    printf("Hello world\n");
}

 

workarounds are to compile the offending .c files with the Visual C++ compiler or "compile as C++"

0 Kudos
6 Replies
Viet_H_Intel
Moderator
1,616 Views

Please use VS2019 versions which released before the compiler released date

0 Kudos
AndrewC
New Contributor III
1,616 Views

As it is well known Visual C++ 2019 pushes point updates on users quite agressively. Reverting to previous point releases of Visual Studio is very difficult if not impossible as the actual version needed may not be downloadable. The information I am providing is

- useful for other users to avoid the issue

- useful for Intel as they will have to fix the issue in a subsequent release

-useful if Intel has a suggested workaround beyond compiling as C++ or with the Visual C++ compiler.

If you know of a workaround, that would be a helpful comment.

 

 

 

 

0 Kudos
Viet_H_Intel
Moderator
1,616 Views

Issue is that we can't test the compiler if the version of VS2019 weren't available.

0 Kudos
AndrewC
New Contributor III
1,616 Views

I realize this is a no-win situation for Intel. Some people like the pace of updates of Visual Studio - I am not so sure it really benefits everyone.

Just a question, on Windows,is there a flag to say "compile as C++" when passed a .c file ?

On linux one can use the "-x c++" option, but that does not exist for Windows.

0 Kudos
Viet_H_Intel
Moderator
1,616 Views

How about /Tp<file>?

0 Kudos
tabriz__meisam
Beginner
1,616 Views

Adding “/Tp” to the additional options list of the command line solves this issue. But a few minor fixes (e.g. explicit casting of the void pointers) will be in order.

0 Kudos
Reply