cgen: C++ compiler support - Part 1

pull/4812/head
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' {
return '_MSC_VER'
}
'cplusplus' {
return '__cplusplus'
}
// other:
'debug' {
return '_VDEBUG'

View File

@ -65,8 +65,14 @@ const (
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 <stdlib.h>
#ifdef __cplusplus
#include <utility>
#define _MOV std::move
#include <execinfo.h>
#endif
//#include "fns.h"
#include <signal.h>
@ -370,11 +376,13 @@ typedef map map_int;
typedef map map_string;
typedef byte array_fixed_byte_300 [300];
typedef byte array_fixed_byte_400 [400];
#ifndef __cplusplus
#ifndef bool
typedef int bool;
#define true 1
#define false 0
#endif
#endif
'
bare_c_headers = '