Error message:
/home/xx/test/main.c: In function ‘main’:
/home/xx/test/main.c:37:21: error: storage size of ‘start’ isn’t known
37 | struct timespec start, end; //nanoseconds
| ^~~~~
/home/xx/test/main.c:37:28: error: storage size of ‘end’ isn’t known
37 | struct timespec start, end; //nanoseconds
| ^~~
/home/xx/test/main.c:43:5: warning: implicit declaration of function ‘clock_gettime’ [-Wimplicit-function-declaration]
43 | clock_gettime(CLOCK_MONOTONIC, &start);
| ^~~~~~~~~~~~~
/home/xx/test/main.c:43:19: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
43 | clock_gettime(CLOCK_MONOTONIC, &start);
| ^~~~~~~~~~~~~~~
/home/xx/test/main.c:43:19: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [CMakeFiles/WBSM4.dir/build.make:63: CMakeFiles/xx.dir/test/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/xx.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Solution:
Add a compiler to the cmakelists.txt file:
add_compile_options(-D_POSIX_C_SOURCE=199309L)
Solution source [copyright infringement and deletion]:
c++ – error: ‘CLOCK_ MONOTONIC’ undeclared (first use in this function) – Stack Overflow
error: ‘CLOCK_ Mononic ‘undeclared problem solving_ Whahu 1989 column – CSDN blog
Read More:
- IOS reverse error: use of undeclared identifier ‘mshookivar’
- Undeclared identifier CV in opencv4.2.0_ WINDOW_ AUTOSIZE
- “Undeclared identifier” still reported in declaration header file
- Use of rep function in R
- Error in the latest version of ffmpeg: ‘codec’_ FLAG_ GLOBAL_ Header ‘undeclared identifier solution
- error C2065: “_ LPW “: undeclared identifier
- How to use C + + function pointer array
- dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
- Error 3 error C2065: ‘endl‘ : undeclared identifier-Error 2 error C2065: ‘cout‘ : undeclared identif
- error: invalid use of non-static member function
- The use of C + + template function and lambda expression
- How to Use the Reverse() Function
- error C2065: ‘_beginthread‘ : undeclared identifier
- There will be row spacing problems in algorithm use in latex. Please use the ‘setstretch {1.35}
- Error C2065 ‘cout’: undeclared identifier
- nvalid default value for prop “params“: Props with type Object/Array must use a factory function to
- Using curl to generate gnutls_ Handshake() failed: error in the pull function or gnutls recv error: error in the pull function
- error C2065: ‘cout’ : undeclared identifier
- To solve the error of T2a w2a a2w, error c2065:_ LPW “: undeclared identifier