ccross-platformposixconfigurertems

"PTHREAD_RWLOCK_INITIALIZER undeclared" error in buiding RTEMS


The error occured in buiding RTEMS-4.11 and used configure param "--enable-posix" in the source file "posix/src/prwlockinit.c"

if ( *rwlock == PTHREAD_RWLOCK_INITIALIZER ) {
  eno = pthread_rwlock_init( rwlock, NULL );
} else {
  eno = 0;
}

the log shows "cpukit/posix/src/prwlockinit.c:42:19: error: 'PTHREAD_RWLOCK_INITIALIZER' undeclared (first use in this function)"

when i used shell command: grep -r "PTHREAD_RWLOCK_INITIALIZER" in the rtems source diractory, i got nothing about this macro declared.

how can i fix this problem with "--enable-posix" not "--disable-posix" ?


Solution

  • You need to use an up-to-date compiler. The problem is the libc (newlib) that is compiled in your gcc is outdated. The PTHREAD_RWLOCK_INITIALIZER was added in Jan 2013.

    Your best bet is to use the RTEMS Source Builder to create the most recent compiler for whichever version of RTEMS you use. For the 'master' branch of RTEMS currently, that would be version 4.11.