I'm returning to the Arduino world after developing a lot of dedicated embedded C code. And I'm immediately stumped on something simple. Here's the error message:
/var/folders/7x/bsz1mn9d5ps8pzs886s71d9m0000gq/T/arduino_build_250184/sketch/taos_test_support.c: In function 'taos_assert':
taos_test_support.c:8:5: error: 'Serial' undeclared (first use in this function)
Serial.print(func);
^
Here's my sketch and supporting C file:
// file: taos_list_test.ino
#include "taos_test_support.h"
void setup() {
Serial.begin(19200);
Serial.println("hello...");
TAOS_ASSERT(1 == 2);
}
void loop() {
}
// file: taos_test_support.h
#ifndef TAOS_TEST_SUPPORT_H
#define TAOS_TEST_SUPPORT_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TAOS_ASSERT(expr) taos_assert((expr), __func__, __FILE__, __LINE__)
void taos_assert(const bool expr,
const char *const func,
const char *const file,
const int line);
#ifdef __cplusplus
}
#endif
#endif // #ifndef TAOS_TEST_SUPPORT_H
// file: taos_test_support.c
#include "taos_test_support.h"
// #include <Serial.h> -- see note
void taos_assert(const bool expr,
const char *const func,
const char *const file,
const int line) {
if (!expr) {
Serial.print(func);
Serial.print(" failed:");
Serial.print(file);
Serial.print(":");
Serial.print(line);
Serial.println();
}
}
Other info:
- Arduino v 1.8.8 for MacOS
- Board = Adafruit ItsyBitsy 32u4
It does not surprise me that Serial is undeclared. But I've not yet figured out how to include. On line 3 of taos_test_support.c, I've tried pretty much every combination I can think of:
#include <Serial.h>
#include <Serial>
#include "Serial.h"
#include <serial.h>
#include <serial>
... but those all result in "Serial: No such file or directory" or similar errors.
What am I missing?