0

I have a very simple eclipse C++ project with the following three files:

header.h

#ifndef HEADER_H_
#define HEADER_H_

#include <cstdint>
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>

void func1();


#endif

src.cc

#include "header.h"

void func1() {

}

main.cc

#include "header.h"

int main(int argc, char** argv) {
   return 0;
}

When I try to compile the project, the compilation goes but it says:

make all
Building file: ../main.cc
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cc"
In file included from ../main.cc:8:
../header.h:11:19: warning: cstdint: No such file or directory
../header.h:12:21: warning: cinttypes: No such file or directory
Finished building: ../main.cc

Building file: ../src.cc
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src.d" -MT"src.d" -o "src.o" "../src.cc"
In file included from ../src.cc:8:
../header.h:11:19: warning: cstdint: No such file or directory
../header.h:12:21: warning: cinttypes: No such file or directory
Finished building: ../src.cc

Building target: Test
Invoking: Cross G++ Linker
g++  -o "Test"  ./main.o ./src.o
Finished building target: Test

Namely it can't find the headers cstdint and cinttypes, is there something I can check to understand why they're not found?

user8469759
  • 2,522
  • 6
  • 26
  • 50

1 Answers1

0

The cstdint header was introduced in C++11, which GCC does not default to. In your project properties, select Settings under C/C++ Build. On the Tool Settings tab, under GCC C++ Compiler, select Dialect. Set the Language standard setting to ISO C++ 11 (or newer if you prefer). Recompile.

enter image description here

Tom
  • 7,269
  • 1
  • 42
  • 69