I recently started using C to develop MTK platform games and found many problems!
Or the requirements of Embedded C, as a JAVA programmer, these points of attention are relatively hindered in program development!
1. The variable Declaration must be placed near {
For example
- view plaincopy to clipboardprint?
- void setFightState( int _fightState )
- {
- int i=0;
- fightState = _fightState;
- }
The two lines of code in the method body cannot be changed because the variable Declaration must be close {
This is the requirement of the embedded compiler and cannot be changed!
But there will be a prompt for VC6!
2. Many Standard C functions cannot be used, such
Rand ();
Use the method mrc_rand () provided by the SDK ();
No error is prompted for this VC6!
Of course, if the parameter IDE is added to the method, no prompt will be displayed!
This may be a poor version of VC6! Or the parameter is void.
In short, developers cannot be prompted in a timely manner to greatly reduce productivity!
3. You cannot assign values to global variables during initialization.
For example
I have a global coordinate array.
- view plaincopy to clipboardprint?
- int posX[] = { 70, 64, 26, 32, 176, 170, 208, 214 };
This definition cannot obtain real data on a real machine,
The global variable is initialized to 0,
It is not intuitive to assign values to a method.
For example
- void init_arena_data()
- {
- posX[0]=70; posX[1]=64; posX[2]=26; posX[3]=32; posX[4]=176; posX[5]=170; posX[6]=208; posX[7]=214;
- }
These data cannot be initialized and assigned values, so it is difficult to use constants to describe arrays.
4. When loading an image file, you cannot obtain the width and height of the image!
5. The length obtained by the sizeof () method does not match the actual number of bytes occupied
- Typedef struct
- {
- Int8 moduleID; // The metadata ID.
- Int8 x; // element offset Coordinate
- Int8 y;
- } ModuleApp; // The data used by the metadata in the frame.
- Typedef struct
- {
- Int8 moduleAppCount; // number of elements
- ModuleApp * moduleApp; // array of Elements
- } Frame; // Frame data
If sizeof (Frame) is used, the result is 8. This is because alignment is required when the computer manages the memory, so it is not the result of human imagination such as 5, 4, and 7!
6. array length cannot be obtained
This may be a headache for Java programmers!
But C has C's rules, but it's just uncomfortable!
7. The difference between C and Java will not be mentioned!
The above comes from skey's bubble SDK,
I am very confused. Maybe you are a Java programmer Writing C Programs!
Maybe you can use it!