Skip to content

Commit

Permalink
add Cwchar_t and update docs. closes JuliaLang#2907
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 22, 2013
1 parent d7b6138 commit 27cf333
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ typealias Cuint Uint32
if OS_NAME === :Windows
typealias Clong Int32
typealias Culong Uint32
typealias Cwchar_t Uint16
else
typealias Clong Int
typealias Culong Uint
typealias Cwchar_t Int32
end
typealias Cptrdiff_t Int
typealias Csize_t Uint
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export
Culonglong,
Cfloat,
Cdouble,
Cwchar_t,
#Ccomplex_float,
#Ccomplex_double,

Expand Down
14 changes: 9 additions & 5 deletions doc/manual/calling-c-and-fortran-code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ Julia type with the same name, prefixed by C. This can help for writing portable
+------------------------+-------------------+--------------------------------+
| ``ptrdiff_t`` | ``Cptrdiff_t`` | ``Int`` |
+------------------------+-------------------+--------------------------------+
| ``ssize_t`` | ``Cssize_t`` | ``Int`` |
+------------------------+-------------------+--------------------------------+
| ``size_t`` | ``Csize_t`` | ``Uint`` |
+------------------------+-------------------+--------------------------------+
| ``complex float`` | ``Ccomplex_float`` (future addition) |
Expand Down Expand Up @@ -264,6 +266,9 @@ wide. In C, however, ``int`` is often used for boolean values. Since
``int`` is 32-bits wide (on all supported systems), there is some
potential for confusion here.

Julia's ``Char`` type is 32 bits, which is not the same as the wide
character type (``wchar_t`` or ``wint_t``) on all platforms.

A C function declared to return ``void`` will give ``nothing`` in Julia.

**System-dependent:**
Expand All @@ -277,11 +282,10 @@ A C function declared to return ``void`` will give ``nothing`` in Julia.
``Int32`` (Windows)
``unsigned long`` ``Culong`` ``Uint`` (UNIX)

``Int32`` (Windows)
``wchar_t`` ``Char`` Although ``wchar_t`` is technically
system-dependent, on all the
systems we currently support (UNIX),
it is 32-bit.
``Uint32`` (Windows)
``wchar_t`` ``Cwchar_t`` ``Int32`` (UNIX)

``Uint16`` (Windows)
====================== ============== =======

For string arguments (``char*``) the Julia type should be ``Ptr{Uint8}``,
Expand Down

0 comments on commit 27cf333

Please sign in to comment.