Stack Exchange
std::mktime return -1 on QNX
C++11
Have a cross platform code with usage of std::mktime on Ununtu 18 (x64) and QNX (x64)
On Ubuntu everything is ok. But on QNX mktime returns -1. errno = 3
What's wrong?
#include <iostream>
#include "ctime"


int main(int argc, char *argv[]){

    const std::string token = "100901";

    std::string dd = token.substr( 0, 2 );
    std::string mm = token.substr( 2, 2 );
    std::string yy = token.substr( 4, 2 );

    struct std::tm date_tm = {};

    date_tm.tm_mday = std::stoi( dd);
    date_tm.tm_mon = std::stoi( mm) - 1;
    date_tm.tm_year = std::stoi( yy) + 100;

    if (std::mktime( &date_tm ) == -1);
    {
        std::cout << "Error";
    }

    return 0;
}

P.S. Tried init struct tm as:
struct std::tm date_tm = {0};

std::memset( &date_tm, 0, sizeof( date_tm ) )


Some notes:
1) if I call mktime twice - everything will be ok (will receive time)
2) tm structure print
tm_gmtoff: 0
tm_hour: 0
tm_isdst: 0
tm_mday: 10
tm_min: 0
tm_mon: 8
tm_sec: 0
tm_wday: 0
tm_yday: 0
tm_year: 101

Are there any other (easy and fast) ways to get time in seconds for my case?

What is the value of errno?

@eerorika The value is 3

What's the error message? Use strerror

Please post a [mcve].

POSIX only stipulates that mktime may set errno on failure, not that it should. The QNX documentation does not mention it at all, while also claiming POSIX compliance, so it's possible that it's not set.

@eerorika Error msg: No such process

On QNX device this problem was fixed by setting to tm structure tm_isdst = 1 and tm_zone (GMT)
Unfortunately it broke my Ubuntu build (due to timezone, on my local PC it was EET).
Replaced receiving seconds by boost::poxis_time
    struct tm date_tm;
    std::memset( &date_tm, 0, sizeof( date_tm ) );
    strptime(token.c_str(), "%d%m%y", &date_tm);

    boost::posix_time::time_duration diff
        = boost::posix_time::ptime( boost::gregorian::date_from_tm( date_tm ) )
          - boost::posix_time::ptime( boost::gregorian::date( 1970, 1, 1 ) );

    date = diff.ticks( ) / boost::posix_time::time_duration::rep_type::ticks_per_second;


