Public Group

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

This topic is 1117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites

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

Edited by Alberth

##### Share on other sites

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)

##### Share on other sites
Not really, sorry. I work and program at Linux only.

##### Share on other sites

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

##### Share on other sites

- 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).

##### Share on other sites

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.

##### Share on other sites
#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 "

##### Share on other sites
#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 :)

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 9
• 21
• 9
• 31
• 16
• ### Forum Statistics

• Total Topics
632618
• Total Posts
3007462

×