Advertisement

[tinydir] "error: '_splitpath_s' was not declared in this scope"

Started by August 28, 2015 08:20 AM
8 comments, last by Acharis 9 years, 4 months ago

I'm getting "error: '_splitpath_s' was not declared in this scope" when trying to complie "tinydir.h". Code::Blocks (the default MinGW which came with it), Windows.

Ideas?

Is tinydir.h even worth using? I thought it was quite popular & tested lib.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

It looks like a mismatch on the meaning of _WIN32. https://github.com/cxong/tinydir/blob/master/tinydir.h uses it to have a Windows-specific case in the code with your _splitpath_s (line 479) variable. MingW is a gcc compiler, so it most likely doesn't have Windows specific code, but it defines _WIN32 probably because it's a Windows compiler.

Not sure who is wrong here. The tinydir project only seems to state Windows, rather than specific compilers.

MingW does seem to have it

Advertisement
(for some reason, the editor refused the text below in my previous message)


http://mingw-w64.sourcearchive.com/documentation/0~20100125-3/stdlib__s_8h-source.html


shows _split_path_s protected under #ifndef POSIX
a gcc compiler is likely POSIX compliant, which means that the function is not defined in mingw

Thanks.

OK, another question then.

Do you know a simple way of getting directory listing that meets these conditions:

- crossplatform (Win, Mac, Linux)

- it works on VC++ & MinGW

- small (no boost, etc)

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Not really, sorry. I work and program at Linux only.


Do you know a simple way of getting directory listing that meets these conditions:
- crossplatform (Win, Mac, Linux)
- it works on VC++ & MinGW
- small (no boost, etc)

There is experimental <filesystem> include. At least on Visual Studio it does exist, not sure about GCC / MinGW:

http://en.cppreference.com/w/cpp/experimental/fs

Advertisement


- crossplatform (Win, Mac, Linux)
- it works on VC++ & MinGW
- small (no boost, etc)

Pick two:

crossplatform + small:

Use the POSIX opendir() and readdir()

works on VC++ & MinGW + small:

Use WIN32 FindFirstFile() and FindNextFile()

crossplatform + works on VC++ & MinGW:

use FindFirstFile() on Windows and opendir() everywhere else


There is experimental include. At least on Visual Studio it does exist, not sure about GCC / MinGW:

Can't find it in my version (MinGW64 GCC 5.2.0).

blah :)

Another idea, how to check if POSIX is available (#define of some sort)? I then would use POSIX when available and if not use Windows code (because it seems Windows VC++ is the only platform that does not have it). I mean, it should be less error prone since I'm not checking for specific compiler or OS but for a library.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

#ifdef POSIX
// do posix things
#else
// do windows things
#endif
"#ifdef" means "if defined ", there is also #ifndef.
If you want to test for a 'true' value, it would be "#if "

#ifdef POSIX
// do posix things
#else
// do windows things
#endif
"#ifdef" means "if defined ", there is also #ifndef.
If you want to test for a 'true' value, it would be "#if "

But to check for POSIX I first need to include <dirent.h> since that's where it's declared, right? Therefore I can't check it since I can't include dirent.h on VC++ since it has no such header and it would throw an error. I need to include dirent.h inside the #ifdef POSIX :)

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

This topic is closed to new replies.

Advertisement