Question

I am trying to compile a relatively simple application that I obtained from the web..

When running make I get the following error:

In file included from main.cpp:2:0:
os.h: In function ‘void myOpenDir(const char*)’:
os.h:13:16: error: ‘chdir’ was not declared in this scope

The file os.h looks like this:

#ifndef OS_H
#define OS_H


#if defined(__GNUG__)

#define INT64 long long
#define UINT64 unsigned long long
#include <dirent.h>
#define SPRTR '/'
void myOpenDir(const char* dirpath)
{
    chdir(dirpath);
}

#elif defined(_MSC_VER)
    #define INT64 __int64
    #define UINT64 unsigned __int64
    #include <direct.h>
    #define SPRTR '\\'
    void myOpenDir(const char* dirpath)
    {
        _chdir(dirpath);
    }
        #else
        #error "Platform not supported. Need to update source code"
        #endif 
#endif

Someone got an idea why it wont compile?

I also used a g++ compiler via g++-4.7.real -c main.cpp but so far no luck.

Était-ce utile?

La solution

Add #include <unistd.h>, as per the chdir manual.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top