cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE: __attribute__((__packed__)) does not work; Build a File - no console output

ColdWeather
Senior

Hello,

Two questions.

First one: __attribute__((__packed__)) does not work: for a structure

typedef __attribute__((__packed__)) struct a_s {
 
  uint32_t M;
  uint16_t V;
  uint8_t Data[1];
 
} Type_A;

sizeof(Type_A) returns 8, not 7.

Second one: after STM32CubeIDE update to 1.10.1 when "Build a selected file" (*.c), the file seems to be processed, but NO build results more seen in the CDT Build Console.

Any ideas?

19 REPLIES 19

Thanks for your replies.

  1. sizeof(Type_A) sould return 7 for the structure, not 8. It returns the desired/correct 7 only, if __attribute__((packed)) or __attribute__((__packed__)) is placed just before Type_A. I talked to a friend working with gcc (some other IDE), too, and he confirmed having had faced the same problem and applied the same solution.
  2. Well, in another workspace the console shows the build results of a single file as expected and as it has been before. I have no idea, what option of the IDE I might have changed under the "broken" workspace... When building the entire project (not a single file only), the console shows the results as usual.

Thanks! I inserted

static_assert(sizeof(Type_A) == 7);

for the case in my code...

To the second question about "no console output while building a single file".

I found out, that in the "good" workspace I can choose either "internal" or "external" builder under "Properties->C/C++ Build->Builder Settings", and both work fine. Besides, if I build a single file, regardless of the setting, the console shows:

15:59:45 **** Building Selected Files of configuration Debug for project CAT ****

Info: Internal Builder is used for build

...

15:59:45 Build Finished. 0 errors, 0 warnings. (took 301ms)

In the "bad" workspace choosing the "internal" builder and trying to build a project, a severe error occures:

Errors occurred during the build.

Errors running builder 'CDT Builder' on project 'Basic'.

Internal error building project Basic configuration Debug

java.lang.NullPointerException

Internal error building project Basic configuration Debug

java.lang.NullPointerException

So, I think, the problem is not in the console but in the fact, that the internal builder is invoked to build a single file, it crashes, and the console has nothing to show!

Now the question is, how to repare this issue with the internal builder?

Semer CHERNI
ST Employee

About the second question I think that you accidently clicked on "Pin Console".

0693W00000Stg5AQAR.png 

Check if the button shown in the screenshot is not pressed on any console in your workspace.

Kind regards,

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

In the "good" workspace it does not matter, pinned or not: I see the output of the builder anyway. The main issue is no more the console but the fact, under the "bad" workspace the internal builder crashes:

0693W00000StgD9QAJ.pngLater, since for building of a single file always the internal builder seems to be engaged, it crashes silently, and the console shows nothing...

Semer CHERNI
ST Employee

Hello @ColdWeather​ 

Could you please send me the workspace .log file to be able to further do analysis the issue.

This file is found under the workspace directory under ".metadata".

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thank you for helping me!

I discovered an interesting thing: under the "bad" workspace I have actually two projects: "Basic" and "Mowitec", and the last one can be switched to the internal builder w/o any issue! Thus, it must be some project setting(s) for "Basic" that make(s) the internal builder crash.

I closed the IDE, deleted *.log files, started again and built both "Mowitec" and "Basic". The log file is under the link:

https://drive.google.com/file/d/1WevKLwnb2cl6cEYKfyFCk7fLMwwM7zX2/view?usp=sharing

Another ST employee not even understanding the problem (structure packing) because of a lack of the basic C language and compiler knowledge...

Semer CHERNI
ST Employee

Hello

We do not support the CDT internal builder.

May I ask why you want to use the Internal builder?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

I'm afraid, you did not read my previous report regarding two projects under the workspace with the issue. Regardless of your assert, if you support or not the internal builder, the symptoms are that the IDE does support both builders, and when building/translating a single file the internal builder is engaged regardless of the project setting "use internal" or ".. external" builder. I have no issue to use the external one (and I do it!), but the point is, I cannot build a single file (what I used to as a convenient way to check the syntax quickly) because the IDE seems to engage always the internal one for this purpose that crashes in my project "Basic". At the same time, in the same workspace(!), another similar project generates no errors when building a single file. Conclusions:

  • your IDE does support internal CDT
  • some broken project setting under "Basic" makes something to crash (see the log).