0

I have my code working well in Visual Studio and windows but in Xcode i have big problems. First and i am wondering after i remove the direct.h include (in Xcode, mac) I get the following errorenter image description here

Also, my objects from classes that i created (this is not related to direct.h) are all not able to be initialised. Xcode doesn't seem to understand any of my constructors. The error message is shown below. The example is for one of my objects. Any help?enter image description here

Here is one of my classes . Please not that all classes are not loading!!

class p_args{
    public:
        string ts,par,fxd,dir,dato;
        int diFL, RSQtype, runtype, *DATO;
        int Snow2GlacierOption,Snow2GlacierJulianDay,parallel;//Added 02-12-2012 (extra arguments in args.txt)
        int manual,nopt,nopt2,maxn,kstop;
        float pcento;
        p_args();~p_args();
        void getfnames(int);
    };
    p_args::p_args(){};
    p_args::~p_args(){};
    void p_args::getfnames(int plots){//read file names
        int i=0;
        this->DATO=new int[3];
        ifstream inFile;
        inFile.open("ARGS.txt",ios::in);
        if (inFile.is_open()){
            inFile>>this->dir;cout<<"Dir\t"<<this->dir<<"\n";
            inFile>>this->ts;cout<<"ts\t"<<this->ts<<"\n";
            inFile>>this->par;cout<<"par\t"<<this->par<<"\n";
            inFile>>this->fxd;cout<<"fxd\t"<<this->fxd<<"\n";
            inFile>>this->diFL; // multiple lapse
            inFile>>this->manual;//manual control of calib.
            inFile>>this->nopt;
            inFile>>this->nopt2;
            inFile>>this->maxn;
            inFile>>this->kstop;
            inFile>>this->pcento;
            inFile>>this->dato;cout<<lnz<<"BEGIN =\t"<<this->dato<<"\n";
            if(plots==1){   //Use with Grapher
                this->DATO = breakdotstring(dato);
                cout<<this->DATO[0]<<"-"<<this->DATO[1]<<"-"<<this->DATO[2]<<"\n";
                //cin.get();
            }
            inFile>>this->RSQtype;
            if(this->RSQtype==0){cout<<"RSQ = NASH SUTCLIFFE (NSEFF)"<<"\n";} else {cout<<"RSQ = NASH SUTCLIFFE *(1-VOLUMETRIC_ERROR)"<<"\n";}
            inFile>>this->runtype;
            if(this->runtype==0)cout<<"SIMULATING WITH GIVEN PARAMETERS\n";
            if(this->runtype==1)cout<<"PARAMETER STUDY RUN";
            if((this->runtype!=0) & (this->runtype!=1) ){cout<<"OPTIMISING RUN";}
            cout<<lnz;
            inFile>>this->Snow2GlacierOption;//Added 02-12-2012 (extra arguments in args.txt)
            cout<<this->Snow2GlacierOption<<"--Snow2GlacierOption\n";
            inFile>>this->Snow2GlacierJulianDay;//Added 02-12-2012 (extra arguments in args.txt)
            cout<<this->Snow2GlacierJulianDay<<"--Snow2GlacierJulianDay\n";
            if(this->Snow2GlacierOption==0)cout<<"Snow Storage On Julian Day["<<this->Snow2GlacierJulianDay<<"] Not Converted to Glacier\n";//Added 02-12-2012 (extra arguments in args.txt)
            if(this->Snow2GlacierOption==1)cout<<"Snow Storage On Julian Day["<<this->Snow2GlacierJulianDay<<"] Converted(Zeroed)\n";//Added 02-12-2012 (extra arguments in args.txt)
            cout<<lnz;//Added 02-12-2012 (extra arguments in args.txt)
            inFile>>this->parallel;//Added 02-12-2012 (extra arguments in args.txt)
            //cout<<this->parallel<<"-->1=Parallel/0=Serial Simulation\n";
            if(this->parallel==0)cout<<"SERIAL HBV SIMULATIONS\n";//Added 02-12-2012 (extra arguments in args.txt)
            if(this->parallel==1)cout<<"PARALLEL HBV SIMULATIONS\nEach simulation is 1 Hydrological year\n";//Added 02-12-2012 (extra arguments in args.txt)
            cout<<lnz;//Added 02-12-2012 (extra arguments in args.txt)
            inFile.close();
        }
    }
jjunju
  • 505
  • 1
  • 5
  • 18
  • @Cyber i will have a look since this may answer the first part but that possibly doesn't answer the second part of my question. Thanks :) – jjunju Mar 20 '15 at 12:52
  • We can't answer the second part because we don't have the code for the constructor of p_args. – Borgleader Mar 20 '15 at 12:54
  • @Borgleader i have added one of my classes. please note that all the classes fail in Xcode with the same error. It doesn't matter whether i use the default constructor or not!! i have checked the includes and they are OK!! – jjunju Mar 20 '15 at 13:01
  • only one question per question, please. – peterchen Mar 20 '15 at 16:38
  • @peterchen when I started the question I thought it as an issue of migrating code from vc++ to Xcode since the code was ok in windows. The issue evolved and hence the confusion. – jjunju Mar 20 '15 at 18:16

1 Answers1

0

I found a way out for dealing with getwcd in Xcode from https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/getcwd.3.html. The solution is similar to that one suggested by @Cyber. I had to do the following changes in my header file;

//#include <direct.h> // for _getcwd WIN
#include <unistd.h> // for getcwd Mac

and use

getcwd()

instead of

_getcwd() 

in my function

void GetCurrentPath(char* buffer){getcwd(buffer,PATH_MAX);}

and then in my function main() I used

//Curent path
    char current_path[PATH_MAX]; //CurrentPath[_MAX_PATH]; windows
    GetCurrentPath(current_path);
    cout << current_path << endl;

The second part of my question was solved by looking at the header files. I had used Xcode to create the empty header file hbv.h and then I had mistakenly pasted the code from my older hbv.h file which I used in VC++ below the #endif instead of above #endif

    #ifndef hbvOptimMAC_hbv_h
    #define hbvOptimMAC_hbv_h
    //<code defining classes was correctly pasted here>
    #endif
    //<code defining classes initially mistakenly pasted here>
jjunju
  • 505
  • 1
  • 5
  • 18