emilk / loguru

A lightweight C++ logging library
The Unlicense
1.76k stars 256 forks source link

MSVC compiler warning #218

Open gha88 opened 2 years ago

gha88 commented 2 years ago

Using version v.2.1.0 and with visual studio compiler at level 3 I received the following errors:

error C4996: 'getenv': This function or variable may be unsafe. error C4996: 'strncat': This function or variable may be unsafe. error C4996: 'strncat': This function or variable may be unsafe. error C4996: 'strncat': This function or variable may be unsafe. error C4996: 'fopen': This function or variable may be unsafe. error C4996: 'strcpy': This function or variable may be unsafe. Of course I can avoid the deprecation using _CRT_SECURE_NO_WARNING but I would prefer do not.

Moreover I received some other warning like C26451 about casting value to a wider type.

zao commented 2 years ago

C4996 is originally a warning, are you building with warnings-as-errors? If so, you may want to exclude it from the set of warnings you treat as errors as it's quite an opinionated warning and recommends non-standard functions just because Microsoft happens to have alternative implementations of them.

gha88 commented 2 years ago

Yes I'm building with warnings as error. As I stated before I can avoid them as you suggest but I think it's not a solution. This configuration is the default on visual studio 19. I think in this case the best solution should be to use a define in case of windows to use the Microsoft implementations. Don't you agree?