Base.ccall (Julia function, in The Standard Library)

ccall(  (symbol, library), RetType, (ArgType1, …), ArgVar1, …)
https://github.com/JuliaLang/julia/blob/master/doc/manual/call/ing-c-and-fortran-code.rst

1. (:function, “library”) pair (must be a constant, but see below).
2. Return type, which may be any bits type, including Int32, Int64, Float64, or Ptr{T} for any type parameter T, indicating a pointer to values of type T, or Ptr{Void} for void* “untyped pointer” values.
3. A tuple of input types, like those allowed for the return type. The input types must be written as a literal tuple, not a tuple-valued variable or expression.
4. The following arguments, if any, are the actual argument values passed to the function.

# ex. The time it takes for the calculation of 100,000 factorial
a = BigInt(1)
t = ccall( (:time, "libc"), Int, () )

- char *getenv(const char *name) example

function getenv(var::String)
 val = ccall( (:getenv, "libc"),
 Ptr{Uint8}, (Ptr{Uint8},), var)
 if val == C_NULL
 error("getenv: undefined variable: ", var)
 end
 bytestring(val)
end

julia> getenv("HOME")
"/home/sosal"

- unsigned int sleep(unsigned int seconds) example

t1 = time()
mySleep = ccall( (:sleep, "libc"), Uint8, (Uint8,), 10)
t2 = time()

println("sleep(3): $(t2-t1)")
# sleep(3): 10.011982917785645

- shared library

# sum.c
include<stdio.h>
include<stdlib.h>

double main(int argc,char* argv[])
{
 double sum = 0;
 int i = 1;

 for( ; i<argc; i++)
 sum += atof( argv[i] );

 return sum;
}

# gcc -shared -fPIC sum.c -o sum.so 

julia> argv = ["", "1.1", "2.35"]
# 3-element Array{ASCIIString,1}:
#  ""
#  "1.1"
#  "2.35"

julia> ccall( (:main, "./sum.so"), Float64,
              (Int32, Ptr{Ptr{Uint8}}), length(argv), argv)

# 3.45