• Advertisement
Sign in to follow this  

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement