sentinel pointers and c strings
This commit is contained in:
@@ -9,6 +9,7 @@ main :: func() void {
|
||||
_ = native.imported_scalar(3, 4)
|
||||
_ = native.child_value(7)
|
||||
_ = native.imported_read(native.imported_handle()?)
|
||||
_ = native.imported_string("hello")
|
||||
_ = native.configured_value(9)
|
||||
signed i8 :: -2
|
||||
unsigned u16 :: 3
|
||||
|
||||
@@ -21,6 +21,7 @@ int imported_add(imported_int_alias left, int right);
|
||||
unsigned long imported_scalar(unsigned char value, unsigned long extra);
|
||||
Imported_Handle *imported_handle(void);
|
||||
int imported_read(const Imported_Handle *handle);
|
||||
int imported_string(const char *value);
|
||||
Imported_Value imported_by_value(Imported_Value value);
|
||||
int imported_volatile(volatile int *value);
|
||||
_Bool imported_bool(_Bool value);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "include/native.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct Imported_Handle {
|
||||
int value;
|
||||
@@ -28,6 +29,13 @@ int imported_read(const Imported_Handle *value) {
|
||||
return value->value;
|
||||
}
|
||||
|
||||
int imported_string(const char *value) {
|
||||
if (strcmp(value, "hello") != 0) {
|
||||
abort();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int imported_variadic(int marker, ...) {
|
||||
va_list args;
|
||||
va_start(args, marker);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
printf :: c_func(format *c_char, ...) c_int
|
||||
|
||||
main :: func() void {
|
||||
_ = printf("answer: %d\n", 42)
|
||||
}
|
||||
Reference in New Issue
Block a user