Is it possible to build the rapid accelerator target without running it
4 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to diagnose why my simulink model won't build in rapid accelerator mode, and I'm stepping through the code sequentially uncommenting out code and clicking run to build the rapid accelerator. When it does build successfully, MATLAB crashes when trying to run the code.
3 件のコメント
Rishi Binda
2018 年 9 月 3 日
Sim_data.c(18405) : error C2099: initializer is not a constant
This can occur due to two reason :
- A function in your code needs to be declared and visible before being used. Function prototypes are recommended, but not strictly required. But visibility to a function definition is required before it is used anywhere. If you are using any functions in your code as a struct member create it's prototype before using it. You can create the prototype in a separate header file.
protocol.h
typedef struct
{
char name[24];
signed int (*Send)(char*, int);
} S_DEVICE;
//prototype here
static signed int myfunc(char* buf, int len);
device.c
#include "protcol.h"
S_DEVICE var = {"ten", myfunc};
int main(void)
{
return 0;
}
//define here
static signed int myfunc(char* buf, int len)
{
return 0;
}
- If you are using C and declaring a constant in your code using
const
then you can try using
#define
The constant you are using may be a "large" object and in C language it is not a constant expression, even if it is declared as const. In C language the term "constant" refers to literal constants (like 1, 'a', 0xFF and so on), enum members etc. This works with C++ though but if its a large object better use #define even in C++.
For example, this is NOT a constant
const int N = 5; /* `N` is not a constant in C */
The above N would be a constant in C++, but it is not a constant in C.
Sim_data.c(18406) : error C2078: too many initializers
This occurs when the number of initializers exceeds the number of objects to be initialized. Somewhere in your code you might be declaring more objects than allowed. Something of this type :
int main() {
int d[2] = {1, 2, 3}; // C2078
int e[2] = {1, 2}; // OK
char a[] = {"a", "b"}; // C2078
char c[] = {'a', 'b'}; // OK
}
NMAKE : fatal error U1077: '"C:\...\win32\Microsoft Visual Studio 2010\VC\Bin\amd64\cl.EXE"' : return code '0x2'
You may be using the MSVC2010 for 64 bit version instead of 32 when you are building. Try reinstalling Visual Studio with the correct version.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Naming Conventions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!