-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
builder,pref: allow thirdparty objects compilation with CPP compiler (#…
- Loading branch information
Showing
9 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module main | ||
|
||
#flag @VMODROOT/implementation.o | ||
#include "@VMODROOT/implementation.h" | ||
|
||
fn C.sizeof_char() int | ||
|
||
fn test_the_implementation_object_file_was_compiled_with_a_c_plus_plus_compiler() { | ||
res := C.sizeof_char() | ||
dump(res) | ||
if res == sizeof(int) { | ||
eprintln('implementation.o was compiled with a C compiler. Fail.') | ||
} else if res == sizeof(char) { | ||
println('implementation.o was compiled with a C++ compiler. Good.') | ||
} else { | ||
eprintln('¯\\_(ツ)_/¯ ... unknown C/C++ compiler') | ||
} | ||
assert res == sizeof(char) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This file should be compiled with a C++ compiler: | ||
extern "C" { | ||
int sizeof_char(void); | ||
} | ||
|
||
int sizeof_char(void) { | ||
// see https://stackoverflow.com/a/12887719/1023403 | ||
return sizeof('a'); // 4 for C compilers, 1 for C++ compilers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int sizeof_char(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Module { | ||
name: 'project_with_cpp_code', | ||
description: 'A simple project, containing a .cpp file with C++ code, that has to be compiled with a C++ compiler.', | ||
dependencies: [] | ||
} |