Differences between Android C ++ release and debug

Source: Internet
Author: User

I encountered a very depressing problem these two days. It was hard to debug the debug version of the common class, and there were many implementation classes and compile them into the release version. In fact, some files could not be opened, some images display incorrect colors. According to the normal idea, they are related to the pre-Debug macro definition, but rester. CPP has been checked several times and has not defined the debug Macro. I have compiled other files into the release version. This file is compiled into the debug version, so there is no problem. There is no way to do this, you can only find this part of the Drawing operation, modify the relevant color assignment, and view the image changes to determine the problematic part.

After a long time, I finally found the problem. The Code is as follows:

(Rgbil *) pix)-> C0 = (rgbil *) pix)-> C0> antishift) & 0x00ff00ffl;
(Rgbil *) pix)-> C1 = (rgbil *) pix)-> C1> antishift) & 0x00ff00ffl;

Rgbil is defined as follows:

Typedef struct _ xrgbil {
U32 C0;
U32 C1;
} Rgbil;

This method assigns a value for 32-bit data at a time. There is no problem in the debug version, but an error occurs in the release version.

Change

PIX-> Blue = (pix-> blue> antishift) & 0xff;
PIX-> Green = (pix-> green> antishift) & 0xff;
PIX-> Red = (pix-> Red> antishift) & 0xff;
PIX-> alpha = (pix-> alpha> antishift) & 0xff;

The pix type is as follows:

Typedef struct _ xrgbi {
2010blue;
2010green;
2010red;
B2alpha;
} Rgbi;

There is no problem with this operation.

The following is also a problem. Direct assignment is a problem. Only one byte and one byte can be assigned a value.
# If defined (_ Android __)
Char * T1 = (char *) (script + POS );
Char * t2 = (char *) & data;

For (INT I = 0; I <4; I ++)
{
* (T2 + I) = * (t1 + I + 4 );
}
For (INT I = 0; I <4; I ++)
{
* (T2 + I + 4) = * (t1 + I );
}

# Else
Xu32 * P = (xu32 *) & data;
Xu32 * PS = (xu32 *) (script + POS );
P [0] = Ps [1];
P [1] = Ps [0];
# Endif

I really don't know how GCC works. What optimizations have been made in the end?

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.