declaration of 'RS::RS(int,)' outside of class is not a definition ERROR

Im attempting to create a library for a remote start program and I keep getting this error

declaration of ‘RS::RS(int, int, int, int, int, int, int)’ outside of class is not definition [-fpermissive]

Here is the error log

Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”

RS.cpp:8:86: error: declaration of ‘RS::RS(int, int, int, int, int, int, int)’ outside of class is not definition [-fpermissive]

RS::RS(int tach21, int wts22, int speed23, int lp16, int gp17, int ign18, int start19);

^

RS.cpp:9:1: error: expected unqualified-id before ‘{’ token

{

^

exit status 1

declaration of ‘RS::RS(int, int, int, int, int, int, int)’ outside of class is not definition [-fpermissive]

Ive attached the .h and .cpp files, if anyone could help point me in the right direction it would be appreciated!
Thanks -Dieselbird

RS.cpp (5.85 KB)

RS.h (1.12 KB)

OP - look in RS.cpp and see how you've declared that method:

RS::RS(int tach21, int wts22, int speed23, int lp16, int gp17, int ign18, int start19);

That semi-colon shouldn't be there.

On closer inspection, you appear to have declared all of your methods using the same format, with a semi-colon tacked on.

The semi-colon is used at the end of a function/method prototype as well as class/struct definitions, etc -- example:

  class MyClass {
    public:
      MyClass (void);
      aMethod (void);
  };

Maybe that's where your confusion is arising, also note that when I declare the aMethod function/method, I must also do:

    // No semi-colons needed, here - but we still need to designate the method as part of MyClass
    // like you did with the RS constructor.
    void
    MyClass::aMethod(void)
    {
       ...
    }

There are a few minor issues in your code, so removing the semi-colons alone will still yield errors but it's little things, fixing the semi-colon thing and the above is a start. If you get more errors after those fixes then please feel free to share.

That makes sense, I was at it too long last night and couldn't focus. I'm still new to c++ and programming in general but I can see where I went wrong.

I'll take a crack at it and see what i come up with, thanks for your help!

Heh, yeah I still do things like this all the time.

It's not uncommon to spend hours pulling your hair out only to take a 5 minute break and then the solution hits you like a brick, sometimes you get so lost in the details that you just need to stop and eat some ice cream.

I'm sure you'll get it sorted.

Okay so after combing through and fixing a bunch of errors, everything seems to be correct but now im getting this error

Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”

core\core.a(main.cpp.o):(.literal._Z8loopTaskPv+0x4): undefined reference to `setup()’

core\core.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to `loop()’

core\core.a(main.cpp.o): In function `loopTask(void*)’:

C:\Users\mattm\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\cores\esp32/main.cpp:14: undefined reference to `setup()’

C:\Users\mattm\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\cores\esp32/main.cpp:17: undefined reference to `loop()’

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board ESP32 Dev Module.

Any ideas mate? Man I could use some icecream :smiley:

RS.cpp (5.81 KB)

RS.h (1.25 KB)

Where are your setup and loop functions defined?

As for the ice cream - sorry, all out, I was coding in JavaScript yesterday and it doesn't get more painful than that.

From the output it looks like you don't have either a setup or loop function defined, but I reckon you still need to define them, even if they're empty - they're already defined, somewhere, so the compiler is expecting them to exist.

If they are defined somewhere then for some reason your compiler seems unable to find them.

I'm more familiar with general programming than specifically the Arduino/hardware stuff so don't quote me on that, but that's my guess.

AHA!! That was the issue, I just added an empty void setup and void loop and it finally compiles!

Whether it will work perfectly with my main program is another question, but we’ll figure that out tomorrow, thanks again for all your help! Time for that ice cream :stuck_out_tongue_closed_eyes:

RS.cpp (5.8 KB)

RS.h (1.25 KB)

Nice one, definitely deserves a small, celabratory treat.

You’ve done the hardest part, really - but if you’re having problems I’m sure someone will be around to help.

Much obliged.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.