Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

'setenv' was not declared in this scope

  • I have a function for converting the time to the local time in my timezone. However, whenever I run the program, I get the error "'setenv' was not declared in this scope"(line 22). I thought that I had #included all the right libraries (<cstdlib.h> <stdlib.h> etc.) and it still gives me this error. Note that the function putenv does not give the same error and according to "this": page they are meant to be in the same library. Anybody know what the problem is?

    @QTime convert_to_tz(QDate theday, double thetime, QString timezone){
    struct tm tm;
    time_t timenum;

    //mktime has the side effect of normalizing tm

    //Get timenum for the UTC time.

    //Convert back to the requested local timezone
    const char * timezoneChar = timezone.toAscii().data();

    //return a value
    return QTime (tm.tm_hour,tm.tm_min);

  • Info about Platform/Compiler version?

  • It says 4.6.3 under Qt version in the Build settings tab. I think that's the compiler version?
    Thanks in advance

  • Operating system??

  • Win 7

  • If you're using Visual Studio version of Qt the setenv function could be not available.
    You could use putenv instead.

    Anyway I suggest to find a solution based on Qt API; like

    QDateTime dt (theday, QTime(0, 0, 0), Qt::UTC);
    QTime tt = dt.addSecs(thetime).toLocalTime().time();
    return QTime(tt.hour(), tt.minute())

Log in to reply