document NIM_EXTERNC for emit (#10022)
This commit is contained in:
parent
c4e3c4ca2d
commit
e1098fa01a
1 changed files with 11 additions and 0 deletions
|
|
@ -7365,6 +7365,17 @@ Example:
|
||||||
|
|
||||||
embedsC()
|
embedsC()
|
||||||
|
|
||||||
|
``nimbase.h`` defines ``NIM_EXTERNC`` C macro that can be used for
|
||||||
|
``extern "C"`` code to work with both ``nim c`` and ``nim cpp``, eg:
|
||||||
|
|
||||||
|
.. code-block:: Nim
|
||||||
|
proc foobar() {.importc:"$1".}
|
||||||
|
{.emit: """
|
||||||
|
#include <stdio.h>
|
||||||
|
NIM_EXTERNC
|
||||||
|
void fun(){}
|
||||||
|
""".}
|
||||||
|
|
||||||
For backwards compatibility, if the argument to the ``emit`` statement
|
For backwards compatibility, if the argument to the ``emit`` statement
|
||||||
is a single string literal, Nim symbols can be referred to via backticks.
|
is a single string literal, Nim symbols can be referred to via backticks.
|
||||||
This usage is however deprecated.
|
This usage is however deprecated.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue