Closed mwtarnowski closed 4 years ago
The "postfix" style is incompatible with MSVC. Do you actually need the deprecated functions? If no, you can specify -DPTHREADPOOL_ALLOW_DEPRECATED_API=OFF
in CMake.
No, I don't need the deprecated functions. I compile my project with -Werror
flag and I just find it surprising that including pthreadpool.h
crashes the compilation. By adding the line #include <pthreadpool.h>
I am forced to define also PTHREADPOOL_NO_DEPRECATED_API
.
The changes shouldn't affect MSVC - currently PTHREADPOOL_DEPRECATED
macro is empty when __GNUC__
is missing. Do you plan using __declspec(deprecated)
for MSVC?
Alternatively, consider disabling the deprecated functions by default and set a flag to enable legacy api for projects that need it.
Yes, I plan to support Windows (and MSVC). However, as the current version probably doesn't compile with MSVC anyway, I figure its ok to merge now, and make it build with MSVC later.
Including
pthreadpool.h
in a source file causes g++ to emit several warnings during compilation, like the following:For some reason g++ cannot recognize that usage of a deprecated type occurs in a function that is marked as deprecated itself. However, when the attribute
deprecated
is placed at the end of a declaration (it is an order suggested by the GCC specification for both functions and types) everything seems ok - the compiler no longer complains.Look also at the snippet in Compiler Explorer.