emilk/loguru

MSVC compiler warning

gha88 opened this issue · 2 comments

gha88 commented

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

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

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?