mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 20:34:21 +00:00
Nim namespace for cpp (#7453)
- new option --usenamespace to generate nim cpp code in its own namespace Nim - minor changes for compatibility with the new Embarcadero = Borland C++-Builder (bcc)
This commit is contained in:
@@ -264,6 +264,11 @@ __clang__
|
||||
# define HAVE_STDINT_H
|
||||
#endif
|
||||
|
||||
/* wrap all Nim typedefs into namespace Nim */
|
||||
#ifdef USE_NIM_NAMESPACE
|
||||
namespace Nim {
|
||||
#endif
|
||||
|
||||
/* bool types (C++ has it): */
|
||||
#ifdef __cplusplus
|
||||
# ifndef NIM_TRUE
|
||||
@@ -413,8 +418,8 @@ typedef struct TStringDesc* string;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct TFrame TFrame;
|
||||
struct TFrame {
|
||||
typedef struct TFrame_ TFrame;
|
||||
struct TFrame_ {
|
||||
TFrame* prev;
|
||||
NCSTRING procname;
|
||||
NI line;
|
||||
@@ -476,6 +481,10 @@ static inline void GCGuard (void *ptr) { asm volatile ("" :: "X" (ptr)); }
|
||||
"error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size" */
|
||||
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
|
||||
|
||||
#ifdef USE_NIM_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define NIM_EXTERNC extern "C"
|
||||
#else
|
||||
|
||||
@@ -295,7 +295,7 @@ else:
|
||||
|
||||
when (defined(x86) or defined(amd64)) and defined(vcc):
|
||||
proc cpuRelax* {.importc: "YieldProcessor", header: "<windows.h>".}
|
||||
elif (defined(x86) or defined(amd64)) and someGcc:
|
||||
elif (defined(x86) or defined(amd64)) and (someGcc or defined(bcc)):
|
||||
proc cpuRelax* {.inline.} =
|
||||
{.emit: """asm volatile("pause" ::: "memory");""".}
|
||||
elif someGcc or defined(tcc):
|
||||
|
||||
Reference in New Issue
Block a user