- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem description
I have different compilation results when specify directories to search for include files via `-I` compiler option and `INCLUDE` environment variable.
Settings
Windows 10 x64 with MSFT VS 2015 Update 2, Intel Parallel Studio XE 2016 Update 2 and Windows 10 SDK 10.0.10586 installed.
Steps to reproduce
Create sample source file (name it 'sample.cpp'):
#include <stdio.h> #include <Windows.h> int main() { printf("hello, world!"); return 0; }
The code above doesn’t require ‘Windows.h’ header but it should be included to show the issue.
Now open Intel compiler “shell” (“Compiler 16.0 Update 2 for Intel 64 Visual Studio 2015 environment” or “Compiler 16.0 Update 2 for IA-32 Visual Studio 2015 environment” shortcut in Start menu).
Check value of `INCLUDE` variable. I have the following (I've added line breaks for convenience):
>set INCLUDE INCLUDE=C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\compiler\include; C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\compiler\include\intel64; C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE; C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE; C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt; C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um; C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared; C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um; C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt; C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\ipp\include; C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\mkl\include; C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\tbb\bin\..\include; C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\daal\include; C:\Program Files (x86)\IntelSWTools\Trace Analyzer and Collector\9.1.2.024\include;
Now compile the code with:
>icl -c sample.cpp
Output is:
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.180 Build 20160204 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. sample.cpp
OK, that’s how it should be. I got the object file.
Now let’s duplicate `INCLUDE` environment variable value with `-I` options and disable the former with -X (or one could do `set INCLUDE=` and omit `-X`):
>icl -c -X "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\compiler\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\compiler\include\intel64" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\ipp\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\mkl\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\tbb\bin\..\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\daal\include" "-IC:\Program Files (x86)\IntelSWTools\Trace Analyzer and Collector\9.1.2.024\include" sample.cpp
Once again I've added line breaks so the entire command can be easily read. This is the same calling of the compiler posted as is, as one line:
>icl -c -X "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\compiler\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\compiler\include\intel64" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\ipp\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\mkl\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\tbb\bin\..\include" "-IC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.2.180\windows\daal\include" "-IC:\Program Files (x86)\IntelSWTools\Trace Analyzer and Collector\9.1.2.024\include" sample.cpp
Here is the compilation output:
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.180 Build 20160204 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. sample.cpp C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\heapapi.h(107): error #1292: unknown attribute "allocator" DECLSPEC_ALLOCATOR ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\heapapi.h(121): error #1292: unknown attribute "allocator" DECLSPEC_ALLOCATOR ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winbase.h(944): error #1292: unknown attribute "allocator" DECLSPEC_ALLOCATOR ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winbase.h(960): error #1292: unknown attribute "allocator" DECLSPEC_ALLOCATOR ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winbase.h(1079): error #1292: unknown attribute "allocator" DECLSPEC_ALLOCATOR ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winbase.h(1089): error #1292: unknown attribute "allocator" DECLSPEC_ALLOCATOR ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winbase.h(8809): warning #3199: "defined" is always false in a macro expansion in Microsoft mode #if MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS /* { */ ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winioctl.h(2705): warning #94: the size of an array must be greater than zero BYTE SerialNumber[0]; ^ C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um\winioctl.h(2883): warning #94: the size of an array must be greater than zero BYTE ParameterList[0]; ^ compilation aborted for sample.cpp (code 2)
I want to emphasize: my problem is not errors themselves, but their occurrence. Why do I have any errors with `-I` options while I have no errors at all when I use corresponding `INCLUDE` environment variable?
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the problem stems from the fact that in the second case (when you use -X and then -I) the directories are no longer considered "system headers" and thus the compiler does not suppress warnings and discretionary errors that are emitted from them.
GNU has a -isystem (in addition to a -I switch) that allows the user to tell the compiler that a directory is a system header directoryUnfortunately Microsoft does not have a switch but with icl.
You could use the undocumented "hidden" icl switch -Qoption,cpp,--sys_include,nameofdir instead of -Inameofdir to workaround this problem.
Judy
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the problem stems from the fact that in the second case (when you use -X and then -I) the directories are no longer considered "system headers" and thus the compiler does not suppress warnings and discretionary errors that are emitted from them.
GNU has a -isystem (in addition to a -I switch) that allows the user to tell the compiler that a directory is a system header directoryUnfortunately Microsoft does not have a switch but with icl.
You could use the undocumented "hidden" icl switch -Qoption,cpp,--sys_include,nameofdir instead of -Inameofdir to workaround this problem.
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Judy, thanks once again! :-)
I never knew "system header" exists for ICL. All I saw in ICC documentation was a reference to "default include directory" without any description. Now with your help I found detailed information about it in GCC documentation.
Your fix works. Thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks judy!
@Rusian: Thanks, I agree and will discuss this with the doc team to add the reference, appreciate much.
Kittur
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page