File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 11#include <stdlib.h>
22
3- _Noreturn void err_c (int code ){
3+ void err_c (int code ){
44 exit (code );
55}
Original file line number Diff line number Diff line change 11#include < cstdlib>
22
3- extern " C " [[ noreturn ]] void err_cpp ( int );
3+ # include " my_error.h "
44
5- [[ noreturn ]] void err_cpp (int code){
5+ void err_cpp (int code){
66 exit (code);
77}
Original file line number Diff line number Diff line change 22extern " C" {
33#endif
44
5+ #if !defined(__has_c_attribute)
6+ # define __has_c_attribute (x ) 0
7+ #endif
8+
9+ #if __has_c_attribute(noreturn)
10+ [[noreturn]]
11+ #elif __has_c_attribute(_Noreturn)
12+ [[_Noreturn ]]
13+ #endif
514void err_c (int );
15+
16+ #if __has_cpp_attribute(noreturn)
17+ [[noreturn]]
18+ #endif
619void err_cpp (int );
20+
721void error_fortran (int *);
822
923#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -16,13 +16,18 @@ add_test(NAME C++_Fortran_error
1616COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:cxx_fortran_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR} /cmake/test_error.cmake
1717)
1818
19- add_executable (fortran_cxx_error error_cpp.f90 ${PROJECT_SOURCE_DIR} /src/error/lib.cpp)
20- set_property (TARGET fortran_cxx_error PROPERTY LINKER_LANGUAGE Fortran)
19+ #object library for Visual Studio
20+ add_library (cpp_err OBJECT ${PROJECT_SOURCE_DIR} /src/error/lib.cpp)
21+ add_executable (fortran_cxx_error error_cpp.f90 $<TARGET_OBJECTS:cpp_err>)
22+ if (NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
23+ set_property (TARGET fortran_cxx_error PROPERTY LINKER_LANGUAGE Fortran)
24+ endif ()
2125add_test (NAME Fortran_C++_error
2226COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:fortran_cxx_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR} /cmake/test_error.cmake
2327)
2428
25- add_executable (fortran_c_error error_c.f90 ${PROJECT_SOURCE_DIR} /src/error/lib.c)
29+ add_library (c_err OBJECT ${PROJECT_SOURCE_DIR} /src/error/lib.c)
30+ add_executable (fortran_c_error error_c.f90 $<TARGET_OBJECTS:c_err>)
2631add_test (NAME Fortran_C_error
2732COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:fortran_c_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR} /cmake/test_error.cmake
2833)
You can’t perform that action at this time.
0 commit comments