cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Simulator compiler isn't allowing a cast but compiler for STM32CubeIDE is

scottSD
Senior III

I am getting a compiler error when casting from a const uint8_t* to a uint8_t* in the simulator but the compiler and debugger in STM32CubeIDE (1.1.0) is allowing this cast.

Is there a way to modify this compiler setting in the TouchGFX Simulator?

Also, any unused variables throw an error instead of a warning in the Simulator. Is there a way to disable this?

1 ACCEPTED SOLUTION

Accepted Solutions

-padantic flag is causing the warning, and -Werror is causing it to become an error. Hope that helps.

View solution in original post

4 REPLIES 4
KMili
Associate III

About casting: it is not a good idea to cast const qualifier away. You should design your code so that it should not be necessary.

About unused declarations: trust me, you don't want to keep all those unused declarations. Current behaviour is not very comfortable at start, but it forces you to keep your code clean and professional. You can use the following construction to overcome warnings about unused variables: (void)yourVar; This does not generate any instructions nor change your code. This is just for compiler to take note.

Although I strongly don't recommend to do that, to overcome ALL warning being treated as error remove -Werror flag in you simulator Makefile.

I am not trying to be rude, but you can try to google it.

Thanks, karolis.

I didn't perceive your reply as rude and I do appreciate the feedback. Although I did not expect a code-development critique. ��

"Google" didn't answer my question about casting for the TouchGFX simulator. I am not trying to be rude, but I DO google first, then search the ST Community when I have an ST-specific question. If I do not find an answer, then I ask my question here. Maybe I was being too general in my question?

TouchGFX version 4.12.3 now allows us to set the ClutFormat argument when creating Dynamic Bitmaps. I am retrieving that CLUT using the method getExtraData() which returns a pointer to the CLUT:

/**
     * @fn const uint8_t* Bitmap::getExtraData() const;
     *
     * @brief Gets a pointer to the extra (alpha) data, if present in the bitmap.
     *
     *        Gets a pointer to the extra (alpha) data, if present in the bitmap. For images
     *        stored in L8 format, a pointer to the CLUT will be returned. For non-opaque RGB565
     *        images, a pointer to the alpha channel will be returned.
     *
     * @note If this bitmap is cached, it will return the cached version of alpha data for this
     *       bitmap.
     *
     * @return A pointer to the raw alpha channel data or CLUT. If no alpha channel or CLUT exist for the given Bitmap, 0 is returned.
     */
    const uint8_t* getExtraData() const;

Notice that it returns a const uint8_t* but also says it returns a cached version of the data if it is cached?

After retrieving the CLUT, I modify it before setting a specific widget's bitmap. This allows me to dynamically modify colors of an image, which is something my application needs to do. The L8 Indexed image format really reduces the amount of resources needed for the image (thanks to the TouchGFX development team!).

Are there other ways to accomplish this?

I found that I can do this when programming to the target as it compiles and works fine. The compiler in the STM32CubeIDE (1.1.0) had no issues with it. However, the TouchGFX simulator complains about this cast so it is basically unusable at this point.

And while I do understand your point that allowing warnings not being a good idea, I would like them allowed during the development process. This is when I use the simulator to quick try something while I am designing my code and sometimes have intermediate "unused variables". I typically go through a clean-up process prior to release and remove these unused variables.

-padantic flag is causing the warning, and -Werror is causing it to become an error. Hope that helps.

karolis,

Thanks for the reply.

It lead me to what I needed to get what I want out of the compiler.