This source file includes following definitions.
- check_struct
- main
#include "Halide.h"
#include <stdio.h>
using namespace Halide;
using namespace Halide::Internal;
struct struct_t {
double a;
int32_t b;
int16_t c;
const char *d;
};
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
extern "C" DLLEXPORT int check_struct(struct_t *s) {
if (s->a != 3.0 ||
s->b != 1234567 ||
s->c != 1234 ||
strcmp(s->d, "Test global string\n")) {
printf("Unexpected struct values: %f %d %d %s\n", s->a, s->b, s->c, s->d);
exit(-1);
}
return 0;
}
HalideExtern_1(int, check_struct, struct_t *);
int main(int argc, char **argv) {
Expr a = cast<double>(3.0f);
Expr b = cast<int32_t>(1234567);
Expr c = cast<int16_t>(1234);
Expr d = std::string("Test global string\n");
Expr s = Call::make(Handle(), Call::make_struct, {a, b, c, d}, Call::Intrinsic);
Func g;
g() = check_struct(s);
g.realize();
printf("Success!\n");
return 0;
}