Skip to main content
t_j_l
Associate II
Dec 9, 2025 1:54 AM UTC
Question

sometimes some unnecessary #include statements automatically added.

When writing code, it is common to encounter the automatic inclusion of some unnecessary #include statements. For example, when I input "NULL" and press the Enter key, it will automatically add " #include <cstddef> ".5d4efb0c-42c5-4875-87f1-2af14162023c.png9e383e1b-8f6b-416c-b886-7a4e14d63698.png

8 replies

TDK
Dec 10, 2025 12:59 AM UTC

This is hard to follow. Where are you inputting NULL? Is this an autocomplete thing?

the IDE shows the file has been modified, but changing the file outside of user code blocks shouldn’t be done.

"If you feel a post has answered your question, please click ""Accept as Solution""."
t_j_l
t_j_lAuthor
Associate II
Dec 10, 2025 1:54 AM UTC

I entered "uint32_t *pi = NULL" in the user code section. When I pressed the Enter key while the code for handling the NULL input was being displayed, it automatically added "#include"

t_j_l
t_j_lAuthor
Associate II
Dec 10, 2025 9:22 AM UTC

I think this is unreasonable. Firstly, if it is to be automatically added, it should be added to the user code area instead of the current location (because this would be overwritten when generating the code using STM32CubeMX). Secondly, the automatically added "#include <cstddef>" is also incorrect and cannot be compiled. It should be "#include <stddef.h>".