1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: C++ compiler support - Part 1

This commit is contained in:
Sumeet Chhetri 2020-05-10 19:56:21 +05:30 committed by GitHub
parent 8aba3eaa07
commit 8dc0c5a699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -2884,6 +2884,9 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) string {
'msvc' { 'msvc' {
return '_MSC_VER' return '_MSC_VER'
} }
'cplusplus' {
return '__cplusplus'
}
// other: // other:
'debug' { 'debug' {
return '_VDEBUG' return '_VDEBUG'

View File

@ -65,8 +65,14 @@ const (
c_headers = ' c_headers = '
// c_headers // c_headers
typedef int (*qsort_callback_func)(const void*, const void*);
#include <stdio.h> // TODO remove all these includes, define all function signatures and types manually #include <stdio.h> // TODO remove all these includes, define all function signatures and types manually
#include <stdlib.h> #include <stdlib.h>
#ifdef __cplusplus
#include <utility>
#define _MOV std::move
#include <execinfo.h>
#endif
//#include "fns.h" //#include "fns.h"
#include <signal.h> #include <signal.h>
@ -370,11 +376,13 @@ typedef map map_int;
typedef map map_string; typedef map map_string;
typedef byte array_fixed_byte_300 [300]; typedef byte array_fixed_byte_300 [300];
typedef byte array_fixed_byte_400 [400]; typedef byte array_fixed_byte_400 [400];
#ifndef __cplusplus
#ifndef bool #ifndef bool
typedef int bool; typedef int bool;
#define true 1 #define true 1
#define false 0 #define false 0
#endif #endif
#endif
' '
bare_c_headers = ' bare_c_headers = '