On z/OS the pthread_t
type is a struct that contains a member char __[8];
. I tried to cast this from a return value to an int64_t
. I got following error:
CCN5216 (S) An expression of type "char [8]" cannot be converted to type "int64_t"
But if I use a temporary variable tmp
it works. I can compile this code with Visual Studio 2015 (defining a custom mypthread
struct similar to zos pthread_t
) without errors. Do you know why the xlc++ has a problem with this cast? Is the cast standard conform?
#define _OPEN_THREADS
#include <iostream>
#include <stdint.h>
#include <pthread.h>
pthread_t apr_os_thread_current() {
return pthread_t();
}
int64_t getId() {
pthread_t tmp = apr_os_thread_current();
return (int64_t) tmp.__; // ok
//return (int64_t) apr_os_thread_current().__; // CCN5216
//return reinterpret_cast<int64_t>(apr_os_thread_current().__); // CCN5216
}
int main() {
std::cout << getId() << std::endl;
return 0;
}