Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile concurrent_vector with include winsock2.h or ws2tcpip.h #1407

Closed
cccbbaa opened this issue Jun 16, 2024 · 5 comments
Closed

Can't compile concurrent_vector with include winsock2.h or ws2tcpip.h #1407

cccbbaa opened this issue Jun 16, 2024 · 5 comments
Labels

Comments

@cccbbaa
Copy link

cccbbaa commented Jun 16, 2024

Environment:
Windows 10 22h2
CPU 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Visual Studio 2022 version is 17.10.2
compile in Intel C++ Compiler 2024.1

Description:
I have identified a potential issue when I use tbb::concurrent_map with windows socket. There's no problem when I just include tbb/concurrent_map.h and use tbb::concurrent_map<int, std::string>. But when I include winsock2.h or ws2tcpip.h, I get a compiler error, like these:

1>In file included from D:\source\repos\test\test\test.cpp:9:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\tbb\concurrent_map.h:17:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_map.h:21:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\detail\_concurrent_skip_list.h:32:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\enumerable_thread_specific.h:26:
1>C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_vector.h(488,21): : error : expected unqualified-id
1>  488 |         return std::min(this->my_size.load(std::memory_order_acquire), capacity());
1>      |                     ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(197,29): note: expanded from macro 'min'
1>  197 | #define min(a,b)            (((a) < (b)) ? (a) : (b))
1>      |                             ^
1>In file included from D:\source\repos\test\test\test.cpp:9:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\tbb\concurrent_map.h:17:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_map.h:21:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\detail\_concurrent_skip_list.h:32:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\enumerable_thread_specific.h:26:
1>C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_vector.h(637,25): : error : expected unqualified-id
1>  637 |             return std::min(curr_vector_size, this->segment_size(seg_index));
1>      |                         ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(197,29): note: expanded from macro 'min'
1>  197 | #define min(a,b)            (((a) < (b)) ? (a) : (b))
1>      |                             ^
1>In file included from D:\source\repos\test\test\test.cpp:9:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\tbb\concurrent_map.h:17:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_map.h:21:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\detail\_concurrent_skip_list.h:32:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\enumerable_thread_specific.h:26:
1>C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_vector.h(924,52): : error : expected unqualified-id
1>  924 |             size_type last_index_to_destroy = std::min(this->segment_base(n_segment) + this->segment_size(n_segment), old_size);
1>      |                                                    ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(197,29): note: expanded from macro 'min'
1>  197 | #define min(a,b)            (((a) < (b)) ? (a) : (b))
1>      |                             ^
1>In file included from D:\source\repos\test\test\test.cpp:9:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\tbb\concurrent_map.h:17:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_map.h:21:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\detail\_concurrent_skip_list.h:32:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\enumerable_thread_specific.h:26:
1>C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_vector.h(968,40): : error : expected unqualified-id
1>  968 |             size_type max_block = std::max(first_block, k);
1>      |                                        ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(193,29): note: expanded from macro 'max'
1>  193 | #define max(a,b)            (((a) > (b)) ? (a) : (b))
1>      |                             ^
1>In file included from D:\source\repos\test\test\test.cpp:9:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\tbb\concurrent_map.h:17:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_map.h:21:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\detail\_concurrent_skip_list.h:32:
1>In file included from C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\enumerable_thread_specific.h:26:
1>C:\Program Files (x86)\Intel\oneAPI\tbb\2021.12\include\oneapi\tbb\concurrent_vector.h(981,37): : error : expected unqualified-id
1>  981 |                 for (; index < std::min(this->segment_size(max_block), curr_size); ++index) {
1>      |                                     ^
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(197,29): note: expanded from macro 'min'
1>  197 | #define min(a,b)            (((a) < (b)) ? (a) : (b))
1>      |                             ^
1>5 errors generated.

This is including the compilation of different files.
recording
recording

@dnmokhov
Copy link
Contributor

Thank you for reporting this, @cccbbaa. Have you tried defining NOMINMAX before including winsock2.h or ws2tcpip.h?

@cccbbaa
Copy link
Author

cccbbaa commented Jun 17, 2024

Thank you for reporting this, @cccbbaa. Have you tried defining NOMINMAX before including winsock2.h or ws2tcpip.h?

Thank you for your reply. That would really help me solve this problem.
Could you tell me why define NOMINMAX can solve this problem?
When I ran into this problem, I thought it was because std::min was not defined. However, including the standard library headers did not solve the problem.

@dnmokhov
Copy link
Contributor

The problem is in the definition of the min and max macros in the Windows Platform SDK headers, which can be disabled with NOMINMAX. You can read here (search in page for "prevent the definition of the min and max Windows-specific preprocessor macros") for more details.

@cccbbaa
Copy link
Author

cccbbaa commented Jun 18, 2024

The problem is in the definition of the min and max macros in the Windows Platform SDK headers, which can be disabled with NOMINMAX. You can read here (search in page for "prevent the definition of the min and max Windows-specific preprocessor macros") for more details.

Thanks for your reply. That really helped me.

@dnmokhov
Copy link
Contributor

Closing the issue. Please reopen if there are any further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants