I am having an issue with my pi where I run gcc or make from the terminal and my main c file included in the compilation is deleted. I am using the wiringPi library to communicate with some sensors via i2c. The code does work, as I have been able to properly compile things without deletion before. But now whenever I run make or gcc the main c file is deleted.
Things look like this:
imu_header.h imu_main.c makefile
My header holds definitions of registers and my main file connects to the device and performs reads and writes. I have also compiled code that did none of that and just printed hello world with the same main file deletion.
Here is my gcc code:
gcc -Wall -o imu_main.c imu_header.h -lwiringPi
Running this deletes the imu_main.c file.
Here is my makefile:
imuRun: imu_main.c imu_header.h
gcc -Wall -o imu_main.c imu_header.h -lwiringPi
When I run make I also lose the imu_main.c file.
I am using the suggested gcc command from the wiringPi blink example:http://wiringpi.com/examples/blink/
Is there a syntax error here and I am doing something wrong? And what does the -Wall parameter do to the gcc command? I have started using a private github repo to store my code and prevent file loss, but this is preventing me from checking if my code even runs. Yesterday I upgraded and updated the Pi with the proper commands but that didn't change anything.
Thank you for your help.
-Mike :)
-o
means "output". You tell GCC to overwrite your C file.