Skip to content

Commit

Permalink
Remove extern "C" from fake declarations.
Browse files Browse the repository at this point in the history
Assuming your C interfaces are appropriately wrapped for C++, it is
unnecessary to force the fakes to be declared extern "C", and doing so
causes any functions declared with C++ linkage to be impossible to fake
due to the conflicting linkage declarations.
  • Loading branch information
zrax committed May 9, 2018
1 parent ef24c19 commit b8f9e65
Show file tree
Hide file tree
Showing 4 changed files with 4,808 additions and 5,105 deletions.
1 change: 1 addition & 0 deletions examples/driver_testing/driver.test.fff.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern "C"{
#include "driver.h"
#include "registers.h"
#include "hardware_abstraction.h"
}
#include "../../fff.h"
#include <gtest/gtest.h>
Expand Down
30 changes: 9 additions & 21 deletions fakegen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,19 @@ def output_macro(arg_count, has_varargs, is_value_function)
puts
output_macro_header(declare_macro_name, saved_arg_count, has_varargs, return_type)
indent {
extern_c { # define argument capture variables
output_variables(saved_arg_count, has_varargs, is_value_function)
}
output_variables(saved_arg_count, has_varargs, is_value_function)
}

puts
output_macro_header(define_macro_name, saved_arg_count, has_varargs, return_type)
indent {
extern_c {
putd_backslash "FUNCNAME##_Fake FUNCNAME##_fake;"
putd_backslash function_signature(saved_arg_count, has_varargs, is_value_function) + "{"
indent {
output_function_body(saved_arg_count, has_varargs, is_value_function)
}
putd_backslash "}"
putd_backslash "DEFINE_RESET_FUNCTION(FUNCNAME)"
putd_backslash "FUNCNAME##_Fake FUNCNAME##_fake;"
putd_backslash function_signature(saved_arg_count, has_varargs, is_value_function) + "{"
indent {
output_function_body(saved_arg_count, has_varargs, is_value_function)
}
putd_backslash "}"
putd_backslash "DEFINE_RESET_FUNCTION(FUNCNAME)"
}

puts
Expand Down Expand Up @@ -453,9 +449,9 @@ def define_fff_globals
}
putd "} fff_globals_t;"
puts
putd_backslash "FFF_EXTERN_C"
putd "FFF_EXTERN_C"
putd "extern fff_globals_t fff;"
putd_backslash "FFF_END_EXTERN_C"
putd "FFF_END_EXTERN_C"
puts
putd_backslash "#define DEFINE_FFF_GLOBALS"
indent {
Expand All @@ -477,14 +473,6 @@ def define_fff_globals
}
end

def extern_c
putd_backslash "FFF_EXTERN_C"
indent {
yield
}
putd_backslash "FFF_END_EXTERN_C"
end

def in_struct
putd_backslash "typedef struct FUNCNAME##_Fake {"
indent {
Expand Down
Loading

0 comments on commit b8f9e65

Please sign in to comment.