parent
0cd11747f1
commit
38f6fee86d
6 changed files with 61 additions and 0 deletions
@ -0,0 +1,16 @@ |
||||
project('c++ and assembly test', 'cpp') |
||||
|
||||
sources = ['trivial.cc'] |
||||
# If the compiler cannot compile assembly, don't use it |
||||
if meson.get_compiler('cpp').get_id() != 'msvc' |
||||
cpu = host_machine.cpu_family() |
||||
sources += ['retval-' + cpu + '.S'] |
||||
cpp_args = ['-DUSE_ASM'] |
||||
message('Using ASM') |
||||
else |
||||
cpp_args = ['-DNO_USE_ASM'] |
||||
endif |
||||
|
||||
exe = executable('trivialprog', sources, |
||||
cpp_args : cpp_args) |
||||
test('runtest', exe) |
@ -0,0 +1,8 @@ |
||||
#include "symbol-underscore.h" |
||||
|
||||
.text |
||||
.globl SYMBOL_NAME(get_retval) |
||||
|
||||
SYMBOL_NAME(get_retval): |
||||
mov r0, #0 |
||||
mov pc, lr |
@ -0,0 +1,8 @@ |
||||
#include "symbol-underscore.h" |
||||
|
||||
.text |
||||
.globl SYMBOL_NAME(get_retval) |
||||
|
||||
SYMBOL_NAME(get_retval): |
||||
xorl %eax, %eax |
||||
retl |
@ -0,0 +1,8 @@ |
||||
#include "symbol-underscore.h" |
||||
|
||||
.text |
||||
.globl SYMBOL_NAME(get_retval) |
||||
|
||||
SYMBOL_NAME(get_retval): |
||||
xorl %eax, %eax |
||||
retq |
@ -0,0 +1,5 @@ |
||||
#if defined(__WIN32__) || defined(__APPLE__) |
||||
# define SYMBOL_NAME(name) _##name |
||||
#else |
||||
# define SYMBOL_NAME(name) name |
||||
#endif |
@ -0,0 +1,16 @@ |
||||
#include<iostream> |
||||
|
||||
extern "C" { |
||||
int get_retval(void); |
||||
} |
||||
|
||||
int main(int argc, char **argv) { |
||||
std::cout << "C++ seems to be working." << std::endl; |
||||
#if defined(USE_ASM) |
||||
return get_retval(); |
||||
#elif defined(NO_USE_ASM) |
||||
return 0; |
||||
#else |
||||
#error "Forgot to pass asm define" |
||||
#endif |
||||
} |
Loading…
Reference in new issue