Search code examples
c++pthreadsicc

ICC 11.1 has strange behaviour regarding PTHREADS on ia64


I'm working on a ia64-machine using ICC 11.1. The following program compiles nicely:

#include <pthread.h>
#include <iostream>
using namespace std;
int main()
{
    cout << PTHREAD_STACK_MIN << '\n';
    return 0;
}

When I compile it with icc test.cpp -o test

BUT when I change the contents of the file to to:

#include <pthread.h>
#include <stdio.h>
int main()
{
    printf("%d\n", PTHREAD_STACK_MIN);
    return 0;
}

I suddenly get:

icc -c test.cpp -o test.o test.cpp(6): error: identifier "PTHREAD_STACK_MIN" is undefined printf("%d\n", PTHREAD_STACK_MIN); ^

compilation aborted for test.cpp (code 2)

Can anyone explain to me why? Or more importantly: how I can work around this issue so that the second code example will also compile?


Solution

  • Well, that's easy: you forgot to include <limits.h> where the PTHREAD_STACK_MIN is supposed to be declared (as per POSIXv6/SUSv3).

    And from the error one can conclude that <iostream> internally also includes the <limits.h> why in C++ mode the error doesn't happen.