Notes for developing MTK programs for JAVA programmers!

Source: Internet
Author: User

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

 
 
  1. view plaincopy to clipboardprint?  
  2. void setFightState( int _fightState )     
  3. {     
  4.     int i=0;     
  5.     fightState = _fightState;     
  6. }   

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.

 
 
  1. view plaincopy to clipboardprint?  
  2. 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

 
 
  1. void init_arena_data()     
  2. {     
  3.     posX[0]=70;  posX[1]=64;  posX[2]=26;  posX[3]=32;   posX[4]=176; posX[5]=170; posX[6]=208; posX[7]=214;      
  4. }   

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

 
 
  1. Typedef struct
  2. {
  3. Int8 moduleID; // The metadata ID.
  4. Int8 x; // element offset Coordinate
  5. Int8 y;
  6. } ModuleApp; // The data used by the metadata in the frame.
  7. Typedef struct
  8. {
  9. Int8 moduleAppCount; // number of elements
  10. ModuleApp * moduleApp; // array of Elements
  11. } 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.