We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I created a simple program with a header file and an external C file for handling low-level functions. I am getting this warning for both of these files,
"HARDWARE.H(30): warning: #1-D: last line of file ends without a newline"
I noticed it was doing the same for the main.c program, so I added a blank space and it went away. This was not the case for the external files. I included the header file in my main.c program.
hardware.h
// Port A Definitions #define SPI_PORT GPIOA #define CS_TEMP GPIO_Pin_4 #define CS_DAC GPIO_Pin_9 #define BRAKE_PORT GPIOA #define BRAKE GPIO_Pin_11 // Port B Definitions #define MAIN_PORT GPIOB #define RESET_MOTOR GPIO_Pin_0 #define COAST GPIO_Pin_1 #define DIRO GPIO_Pin_2 #define PWM GPIO_Pin_6 #define ESF GPIO_Pin_10 #define DIR GPIO_Pin_11 #define FAULT1 GPIO_Pin_12 #define FAULT2 GPIO_Pin_13 #define MODE GPIO_Pin_14
// Functions int get_temperature(void);
hardware.c
#include "hardware.h"
int get_temperature(void) { int dummy; dummy = 16; return dummy; }
I am just trying to get the basic functionality working before I continue. Your help would be appreciated!
Stephen
No need to add a space. Just move to the end of the last line in the file. Then press enter and save.
The warning is there because some tools will only process text that ends with a new-line character, so if the last text isn't followed by a new-line, that text will be ignored.
Almost all tools really process file data to the last character instead of to the last new-line character, but the compiler warning is there just to make sure that you don't get hurt if you move your code between different tools.