0

I have the following files:

KeywordParser.h

#include <Ramp.h>

#ifndef KeywordParser_h
#define KeywordParser_h

extern enum ramp_mode parseRampMode(char* command);
extern enum loop_mode parseLoopMode(char* command);

#endif

KeywordParser.cpp

#include <KeywordParser.h>
#include <Ramp.h>

enum ramp_mode parseRampMode(const char* command) {
  if (strcmp(command, "NONE") == 0) return NONE;
  if (strcmp(command, "LINEAR") == 0) return LINEAR;
// ...

  return NONE;
};

enum loop_mode parseLoopMode(const char* command) {
  if (strcmp(command, "ONCEFORWARD") == 0) return ONCEFORWARD;
  if (strcmp(command, "LOOPFORWARD") == 0) return LOOPFORWARD;
// ...

  return ONCEFORWARD;
};

main.cpp

#include <Arduino.h>
#include <KeywordParser.h>
// a bunch of code, eventually, though, I call the functions

void loop() {
  parseRampMode("NONE");
  parseLoopMode("ONCEFORWARD");
}

I am using PlatformIO to do the compilation. I am including many other header files that work just fine (albeit they aren't for extern enum functions; they're for classes).

Now, though, I get this error for each time I use the functions:

<artificial>: undefined reference to `parseLoopMode(char*)'

<artificial>: undefined reference to `parseRampMode(char*)'

My IntelliSense gives no indication of wrongdoing. Any idea what the problem here is? This is unimaginably frustrating. I have a hint that it has something to do with needing extern "C", but I've tried that.

Thanks in advance.

1 Answers1

0

Wow, thank you Ken White! I looked through the link you showed and found this answer.

The new KeywordParser.h

#include <Ramp.h>

#ifndef KeywordParser_h
#define KeywordParser_h

extern enum ramp_mode parseRampMode(const char* command);
extern enum loop_mode parseLoopMode(const char* command);

#endif

(Look at the parameters.)