Serial commands give errors

I have tried searching around on the web but couldn’t find an answer to my problem.
Using VScode and the platformio extension i am trying to use the Serial.begin and Serial.println commands.
However i keep getting an error that i can’t understand. Here is some example code:
#include <Arduino.h>
#include <HardwareSerial.h>

void setup() {

void loop() {

These are the errors i am getting:

You have named your sourcefile main.c, but it should be main.cpp. Arduino is a C++ framework.

1 Like

If i rename it to cpp i get different problems, also i’m required to use c. Is it possible to use the serial monitor in c?

Which are? There really shouldn’t be any with this simple code…

Since Arduino is a C++ framework, you are pretty much forced to use C++ to interact with and use the Arduino functions such as Serial.println()… This requirement is quite fundamentally at odds with the framework you’re using.

If you want a very, very dirty hack, you can still declare the setup() and loop() functions in their name-mangled versions and use printf() for output I guess?