libc functions from c++ issues

Chris Johns chrisj at rtems.org
Tue Apr 12 06:44:52 UTC 2022


Hi,

The following code:

// aarch64-rtems6-g++ -std=c++98 -c test.o test.cpp
// aarch64-rtems6-g++ -std=c++03 -c test.o test.cpp
// aarch64-rtems6-g++ -std=c++11 -c test.o test.cpp
// aarch64-rtems6-g++ -std=c++17 -c test.o test.cpp
#include <signal.h>
#include <stdlib.h>
void t1(pthread_t thread) {
  ::setenv("ABC", "123", 0);
  ::pthread_kill(thread, SIGINT);
}

produces:

$ arm-rtems6-g++ -std=c++17 -c -o test.o test.cpp






test.cpp: In function 'void t1(pthread_t)':
test.cpp:8:5: error: '::setenv' has not been declared; did you mean 'getenv'?
    8 |   ::setenv("ABC", "123", 0);
      |     ^~~~~~
      |     getenv
test.cpp:9:5: error: '::pthread_kill' has not been declared; did you mean
'pthread_key_t'?
    9 |   ::pthread_kill(thread, SIGINT);
      |     ^~~~~~~~~~~~
      |     pthread_key_t

The same code compiles fine on FreeBSD:

$ c++ -std=c++17 -c -o ../test.o ../test.cpp






$ c++ --version
FreeBSD clang version 6.0.0 (tags/RELEASE_600/final 326565) (based on LLVM 6.0.0)
Target: x86_64-unknown-freebsd11.2
Thread model: posix
InstalledDir: /usr/bin

and Linux:

$ g++ -std=c++17 -c -o test.o test.cpp
$ g++ --version
g++ (Ubuntu 11.2.0-7ubuntu2) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Is there something broken in our newlib?

Thanks
Chris


More information about the devel mailing list