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 1
1
#include <stdlib.h>
2
2
3
- _Noreturn void err_c (int code ){
3
+ void err_c (int code ){
4
4
exit (code );
5
5
}
Original file line number Diff line number Diff line change 1
1
#include < cstdlib>
2
2
3
- extern " C " [[ noreturn ]] void err_cpp ( int );
3
+ # include " my_error.h "
4
4
5
- [[ noreturn ]] void err_cpp (int code){
5
+ void err_cpp (int code){
6
6
exit (code);
7
7
}
Original file line number Diff line number Diff line change 2
2
extern " C" {
3
3
#endif
4
4
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
5
14
void err_c (int );
15
+
16
+ #if __has_cpp_attribute(noreturn)
17
+ [[noreturn]]
18
+ #endif
6
19
void err_cpp (int );
20
+
7
21
void error_fortran (int *);
8
22
9
23
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -16,13 +16,18 @@ add_test(NAME C++_Fortran_error
16
16
COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:cxx_fortran_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR} /cmake/test_error.cmake
17
17
)
18
18
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 ()
21
25
add_test (NAME Fortran_C++_error
22
26
COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:fortran_cxx_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR} /cmake/test_error.cmake
23
27
)
24
28
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> )
26
31
add_test (NAME Fortran_C_error
27
32
COMMAND ${CMAKE_COMMAND} -Dexe=$<TARGET_FILE:fortran_c_error> -Dexp_code=42 -P ${PROJECT_SOURCE_DIR} /cmake/test_error.cmake
28
33
)
You can’t perform that action at this time.
0 commit comments