MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / codegen_data_header

Function codegen_data_header

src/tinympc/codegen.cpp:128–167  ·  view source on GitHub ↗

Create inc/tiny_data.hpp file

Source from the content-addressed store, hash-verified

126
127// Create inc/tiny_data.hpp file
128int codegen_data_header(const char* output_dir, int verbose) {
129 char data_hpp_fname[PATH_LENGTH];
130 FILE *data_hpp_f;
131
132 sprintf(data_hpp_fname, "%s/tinympc/tiny_data.hpp", output_dir);
133
134 // Open data header file
135 data_hpp_f = fopen(data_hpp_fname, "w+");
136 if (data_hpp_f == NULL)
137 ERROR_MSG(EXIT_FAILURE, "Failed to open file %s", data_hpp_fname);
138
139 // Preamble
140 time_t start_time;
141 time(&start_time);
142 fprintf(data_hpp_f, "/*\n");
143 fprintf(data_hpp_f, " * This file was autogenerated by TinyMPC on %s", ctime(&start_time));
144 fprintf(data_hpp_f, " */\n\n");
145
146 fprintf(data_hpp_f, "#pragma once\n\n");
147
148 fprintf(data_hpp_f, "#include \"types.hpp\"\n\n");
149
150 fprintf(data_hpp_f, "#ifdef __cplusplus\n");
151 fprintf(data_hpp_f, "extern \"C\" {\n");
152 fprintf(data_hpp_f, "#endif\n\n");
153
154 fprintf(data_hpp_f, "extern TinySolver tiny_solver;\n\n");
155
156 fprintf(data_hpp_f, "#ifdef __cplusplus\n");
157 fprintf(data_hpp_f, "}\n");
158 fprintf(data_hpp_f, "#endif\n");
159
160 // Close codegen data header file
161 fclose(data_hpp_f);
162
163 if (verbose) {
164 printf("Data header generated in %s\n", data_hpp_fname);
165 }
166 return 0;
167}
168
169// Create src/tiny_data.cpp file
170int codegen_data_source(TinySolver* solver, const char* output_dir, int verbose) {

Callers 1

tiny_codegenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected