Comments (9)
Hmm, interesting. I believe my use of strncpy
here is actually safe. What's the typical solution for this? #if to check if you're compiling on Windows, and use strncpy_s or something if so, otherwise regular strncpy?
from inih.
I've researched this, it seems to be VS2013 (and VS2012) complaining about simple things like fopen
as well, suggesting to use the _s
versions defined in TR 24731
, which is an optional extension of C11.
There's this option to silence it without raising the _CRT_SECURE_NO_WARNINGS
flag everywhere.
BTW I'm using the cpp wrapper. What happens if the ini file is malformed? Can I detect that with reader.ParseError()
right after having initialized the reader with INIReader reader("path")
?
Thanks.
from inih.
@benhoyt yes, and identify windows with #ifdef _WIN32
from inih.
@benhoyt: Yes, it's safe here. A solution could be for users to define _CRT_SECURE_NO_WARNINGS
(with /D
or #define
) by themselves. You could also do it for them.
@AgostinoSturaro: You're mistaken. MS doesn't implement those C11 functions (yet). There are many differences between them.
@andravin: This has nothing to do with Windows itself. There are also other C compilers and standard libraries for Windows.
from inih.
OK, if the strncpy warning is MSVC only, then instead of checking for MS Windows with #ifdef _WIN32, you can check for the MSVC compiler using #ifdef _MSC_VER
I don't think requiring the user to define _CRT_SECURE_NO_WARNINGS is an acceptable solution.
from inih.
You could also do it for them.
That's only one line (#define _CRT_SECURE_NO_WARNINGS
) he has to add before the #include
directives in ini.c
from inih.
Okay, I'm happy to add this to ini.c -- I'll do this in the next few days:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS 1
#endif
from inih.
I don't have ready access to MSVC right now -- can someone please try adding the above #ifdef dance before the #includes in ini.c and ensure the warning goes away? If so, feel free to send a pull request.
from inih.
Fixed in c3458c9 and created release r31 with fix: https://github.com/benhoyt/inih/releases/tag/r31
from inih.
Related Issues (20)
- pkg-config files have version `undefined` HOT 3
- possible NULL pointer dereference HOT 2
- unittest.sh doesn' report that tests succeeded? HOT 1
- Emit ini file HOT 1
- Error attempting to link against libinih HOT 3
- Expected key/section missing error HOT 3
- Do you have plan to support write feature ? HOT 1
- Do you plan support buid with cmake HOT 3
- how to get all the sections, key-value pairs HOT 3
- Seems to not discard the rest of a long line? HOT 4
- meason.build distro_install option HOT 5
- Duplicate keys cause a trailing \n to be appended? HOT 1
- inih v57 fails to build using GCC 4.8.5 on CentOS 7 HOT 3
- Add support for UTF-16 HOT 5
- Add Cflags.private to support static linking on Windows HOT 1
- strncpy0 should be in ini_ namespace HOT 8
- Undefined symbol when linking with LLD HOT 9
- undefined reference to `INIReader
- undefined reference to 'ini_parse'
- When loading the ini file,, all the spaces in the value will be deleted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inih.