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

Windows clang-cl -Wdeprecated-declarations warnings #143

Closed
DaanDeMeyer opened this issue Aug 18, 2018 · 14 comments
Closed

Windows clang-cl -Wdeprecated-declarations warnings #143

DaanDeMeyer opened this issue Aug 18, 2018 · 14 comments

Comments

@DaanDeMeyer
Copy link
Contributor

DaanDeMeyer commented Aug 18, 2018

Compiling doctest with clang-cl (Clang 6.0.1) on Windows results in several Wdeprecated-declarations warnings.

..\third-party\doctest\doctest.h(4205,23):  warning: 'fileno' is deprecated: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _fileno. See online help for details. [-Wdeprecated-declarations]
            if(isatty(fileno(stdout)) == false && p->force_colors == false)
                      ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\stdio.h(2457,28):  note: 'fileno' has been explicitly marked deprecated here
        _Check_return_     _CRT_NONSTDC_DEPRECATE(_fileno)    _ACRTIMP int   __cdecl fileno(_In_ FILE* _Stream);
                           ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\corecrt.h(306,50):  note: expanded from macro '_CRT_NONSTDC_DEPRECATE'
        #define _CRT_NONSTDC_DEPRECATE(_NewName) _CRT_DEPRECATE_TEXT(             \
                                                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\vcruntime.h(245,47):  note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
In file included from ..\test\impl.cpp:3:
..\third-party\doctest\doctest.h(4205,16):  warning: 'isatty' is deprecated: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _isatty. See online help for details. [-Wdeprecated-declarations]
            if(isatty(fileno(stdout)) == false && p->force_colors == false)
               ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\corecrt_io.h(490,24):  note: 'isatty' has been explicitly marked deprecated here
        _Check_return_ _CRT_NONSTDC_DEPRECATE(_isatty)
                       ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\corecrt.h(306,50):  note: expanded from macro '_CRT_NONSTDC_DEPRECATE'
        #define _CRT_NONSTDC_DEPRECATE(_NewName) _CRT_DEPRECATE_TEXT(             \
                                                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\vcruntime.h(245,47):  note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
In file included from ..\test\impl.cpp:3:
..\third-party\doctest\doctest.h(4895,30):  warning: 'strtok' is deprecated: This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
            char* pch = std::strtok(filtersString.c_str(), ","); // modifies the string
                             ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\string.h(438,16):  note: 'strtok' has been explicitly marked deprecated here
_Check_return_ _CRT_INSECURE_DEPRECATE(strtok_s)
               ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\vcruntime.h(255,55):  note: expanded from macro '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\vcruntime.h(245,47):  note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
In file included from ..\test\impl.cpp:3:
..\third-party\doctest\doctest.h(4901,28):  warning: 'strtok' is deprecated: This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
                pch = std::strtok(0, ",");
                           ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt\string.h(438,16):  note: 'strtok' has been explicitly marked deprecated here
_Check_return_ _CRT_INSECURE_DEPRECATE(strtok_s)
               ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\vcruntime.h(255,55):  note: expanded from macro '_CRT_INSECURE_DEPRECATE'
        #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT(    \
                                                      ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include\vcruntime.h(245,47):  note: expanded from macro '_CRT_DEPRECATE_TEXT'
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
                                              ^
  • doctest version: 1.2.9
  • Operating System: Windows 10
  • Compiler+version: Clang 6.0.1

Can be reproduced by compiling https://github.com/DaanDeMeyer/reproc on Windows with clang-cl. If the compile output isn't sufficient to solve the warnings I can add more detailed steps to reproduce.

From a quick look at doctest's source I think Wdeprecated-declarations just needs to be added to the list of ignored warnings.

onqtam added a commit that referenced this issue Aug 19, 2018
@onqtam
Copy link
Member

onqtam commented Aug 19, 2018

you can try the header from the dev branch - this should be silenced now

@DaanDeMeyer
Copy link
Contributor Author

DaanDeMeyer commented Aug 19, 2018

Still getting the same warnings unfortunately. (I copy pasted the header from dev over the one I currently have).

EDIT: Suppressing the warning for the entire file doesn't work either.

@onqtam
Copy link
Member

onqtam commented Aug 19, 2018

I hadn't tested with clang-cl (until now) - I guess both _MSC_VER and __clang__ are defined - so I should change the doctest compiler detection to be able to have both MSVC and Clang detected since the are no longer mutually exclusive... and then the warning suppression with a pragma for clang should work. Will experiment...

onqtam added a commit that referenced this issue Aug 19, 2018
…ction since they are not mutually exclusive because of clang-cl... (+ suppressed a clang warning about strtok)
@onqtam
Copy link
Member

onqtam commented Aug 19, 2018

just pushed a change - try it again and let me know

@DaanDeMeyer
Copy link
Contributor Author

DaanDeMeyer commented Aug 19, 2018

Getting error: use of undeclared identifier 'DOCTEST_REQUIRE'. Probably a typo somewhere in that latest commit.

@onqtam
Copy link
Member

onqtam commented Aug 19, 2018

damn.... I was compiling a hello world test case with clang-cl from the visual studio developer prompt - I was able to get it to compile (no warnings/errors) but not to link - so I don't have it all setup properly yet.

I now noticed that there are a few other places where the compiler checks are used in a mutually-exclusive way - don't know why it isn't error-ing there on my side...... I guess I should set it up and test properly...

onqtam added a commit that referenced this issue Aug 20, 2018
…REQUIRE macro not being defined - was disabling exceptions in the feature detection after clang/msvc became non-mutually exclusive. Also detecting if exceptions are disabled for MSVC properly - relates to 44
@onqtam
Copy link
Member

onqtam commented Aug 20, 2018

I found out the reason for the DOCTEST_REQUIRE problems and I fixed it (along with some other issues) - tested the framework with the LLVM toolchain and it works as expected! try it out :)

@DaanDeMeyer
Copy link
Contributor Author

That fixed it! Thanks for the quick response!

@DaanDeMeyer
Copy link
Contributor Author

I might have spoken too soon. reproc's MacOS CI is failing after including latest doctest.

https://travis-ci.com/DaanDeMeyer/reproc/jobs/140907999

I think an include is missing somewhere but I'm not sure.

@DaanDeMeyer DaanDeMeyer reopened this Aug 21, 2018
@onqtam
Copy link
Member

onqtam commented Aug 21, 2018

Those are linker errors. I have no clue as to why that might be happening. This does not seem related to clang-cl changes - it might be caused by the huge refactoring that took place between versions 1.2.9 and the soon-to-be-released 2.0. Doctest is tested with quite the big build matrix but this calls for further investigation... I'll try to think of something.

@onqtam
Copy link
Member

onqtam commented Aug 21, 2018

So I bisected the history of doctest between version 1.2.9 and 2.0 and since this commit your build starts breaking on OSX:

184b48c

That commit is the biggest in the history of the framework - it was the foundation of the new reporter system based on streams (streams are also in the linker errors)... It is all standard C++ so I would suspect a toolchain issue - I tried specifying explicitly to use the xcode10 osx image on travis - didn't help. I'll have to think a bit more about this.

@onqtam
Copy link
Member

onqtam commented Aug 21, 2018

So... turns out I've already encountered this issue before - and the "solution" was to include <iostream> in the user test file.....

I managed to get your build to work by including <iostream> everywhere - but that is wrong on so many levels. So this indeed is a toolchain issue. I will try to come up with a way to force the linker to pull what is necessary without making you include some seemingly unrelated header.

So after all this isn't related to clang-cl. Will write here soon.

onqtam added a commit that referenced this issue Aug 21, 2018
…em is this: when using clang from xcode - that means libc++. in that case I include <iosfwd> instead of forward-declaring std::ostream myself. Then if the user includes somewhere only the doctest header and <string> and then does a comparison - then and only then will there be some linker issue which I previously had managed to resolve by telling the users to also include <iostream> in that place in their tests. This is a toolchain issue when using the <iosfwd> header - the details are still not clear to me but I managed to get the linker to pull in what is necessary by adding a dummy unused global function in the implementation of doctest that uses operator<< of std::string to print to std::cout.
@onqtam
Copy link
Member

onqtam commented Aug 21, 2018

finally resolved "properly" - turns out the problem is this: when using clang from xcode - that means libc++. in that case I include <iosfwd> instead of forward-declaring std::ostream myself. Then if the user includes somewhere only the doctest header and and then does a comparison - then and only then will there be some linker issue which gets resolved by including <iostream> in the tests. This is a toolchain issue when using the <iosfwd> header - the details are still not clear to me but I managed to get the linker to pull in what is necessary by adding a dummy unused global function in the implementation of doctest that uses operator<< of std::string to print to std::cout.

try the latest version of the header from the dev branch (soon to be released in master as version 2.0!)

@DaanDeMeyer
Copy link
Contributor Author

Everything's green now! Thanks a lot for all the detailed responses. I'll stay on the current dev commit and switch to 2.0 when it releases.

onqtam added a commit that referenced this issue Aug 23, 2018
onqtam added a commit that referenced this issue Aug 23, 2018
…ction since they are not mutually exclusive because of clang-cl... (+ suppressed a clang warning about strtok)
onqtam added a commit that referenced this issue Aug 23, 2018
…REQUIRE macro not being defined - was disabling exceptions in the feature detection after clang/msvc became non-mutually exclusive. Also detecting if exceptions are disabled for MSVC properly - relates to 44
onqtam added a commit that referenced this issue Aug 23, 2018
…em is this: when using clang from xcode - that means libc++. in that case I include <iosfwd> instead of forward-declaring std::ostream myself. Then if the user includes somewhere only the doctest header and <string> and then does a comparison - then and only then will there be some linker issue which I previously had managed to resolve by telling the users to also include <iostream> in that place in their tests. This is a toolchain issue when using the <iosfwd> header - the details are still not clear to me but I managed to get the linker to pull in what is necessary by adding a dummy unused global function in the implementation of doctest that uses operator<< of std::string to print to std::cout.
@onqtam onqtam changed the title Windows clang-cl Wdeprecated-declarations warnings Windows clang-cl -Wdeprecated-declarations warnings Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants