-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
225 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
byvalue | ||
libffi_test* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
gcc -shared -fPIC -rdynamic -o libffi_test.so ffi_test_lib.c | ||
g++ test_byvalue.cpp -L./ -lffi_test -o byvalue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
typedef struct { | ||
int abcd; | ||
struct { | ||
int a; | ||
double b; | ||
} first_struct; | ||
struct { | ||
double c; | ||
int d; | ||
} second_struct; | ||
} ByValue; | ||
|
||
extern const char* byvalue_nested(ByValue bv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdio.h> | ||
#include "byvalue_nested.h" | ||
|
||
|
||
char json_buffer[1024] = { 0 }; | ||
|
||
|
||
const char* byvalue_nested(ByValue bv) { | ||
snprintf(json_buffer,1024,"{\"abcd\":%d \"a\":%d \"b\":%lf \"c\":%lf \"d\":%d}", bv.abcd, | ||
bv.first_struct.a, bv.first_struct.b, | ||
bv.second_struct.c, bv.second_struct.d); | ||
return json_buffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <cstdio> | ||
extern "C" { | ||
#include "byvalue_nested.h" | ||
} | ||
|
||
using namespace std; | ||
|
||
|
||
int main (int c, char** v) { | ||
ByValue bc = { 10, { 5, 4.0 }, {3.0, 9}}; | ||
printf("%s\n", byvalue_nested(bc)); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters