Custom made Library Issues!

Hey fellas! I am Trying to get my own library to work… But I just can’t get it to compile!
I am controlling a motor using 3 relays, I don’t need help with my circuit. Just Coding issues!
Here is my library.cpp File

`/*
  Gearmotor-Driver.cpp - Library for moving a motor in two directions with relays.
  Created by micahthetanker, April 26, 2021.
  Still WIP.
*/

#include "Arduino.h"
#include "Gearmotor-Driver.h"

Motor::ForwardsPin(FP)
{
  pinMode(FP, OUTPUT);
   _FP = FP;
}
Motor::BackwardsPin(BP);
{
  pinMode(BP, OUTPUT);
  _BP = BP;
}
Motor::On/OffPin(O/FP);
{
  pinMode(BP, OUTPUT);
  _O/FP = O/FP;
}
void Motor::Forward()
{
  digitalWrite(FP, HIGH);
  digitalWrite(BP, HIGH);
  digitalWrite(O/FP, HIGH);
}
void Motor::Backward()
{
  digitalWrite(FP, LOW);
  digitalWrite(BP, LOW);
  digitalWrite(O/FP, HIGH);
}
void Motor::Stop()
{
  digitalWrite(FP, LOW);
  digitalWrite(BP, LOW);
  digitalWrite(O/FP, LOW);
}
  
`

And here is my Library.H file

`/*
  Gearmotor-Driver.h - Library for moving a motor in two directions with relays.
  Created by micahthetanker, April 26, 2021.
  Still WIP.
*/
#ifndef Gearmotor-Driver_h
#define Gearmotor-Driver_h

#include "Arduino.h"

class Motor
{
  public:
    int O/FP;
    int BP;
    int FP;
    ForwardsPin(FP);
    BackwardsPin(BP);
    On/OffPin(O/FP);
    void Forward();
    void Backward();
    void On/Off();
  private:
    int _BP;
    int _FP;
    int _O/FP;
};

#endif`

and here is how I used the code

#include <Gearmotor-Driver.h>
Motor ForwardsPin(11);
Motor BackwardsPin(10);
Motor On/OffPin(9);


void setup() 
{  
}

void loop() 
{
  Motor.Forward();
  delay(1000);
  Motor.Stop();
  delay(1000);
  Motor.Backward();
  delay(1000);
  Motor.Stop();
  delay(1000);

}

and here is the error I get…

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"





















In file included from C:\Users\micahthetanker\Documents\Arduino\Test\Test.ino:1:0:

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:6:18: warning: extra tokens at end of #ifndef directive

 #ifndef Gearmotor-Driver_h

                  ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:7:18: warning: ISO C++11 requires whitespace after the macro name

 #define Gearmotor-Driver_h

                  ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:14:9: error: expected ';' at end of member declaration

     int O/FP;

         ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:14:10: error: expected unqualified-id before '/' token

     int O/FP;

          ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:17:17: error: 'FP' is not a type

     ForwardsPin(FP);

                 ^~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:17:19: warning: ISO C++ forbids declaration of 'ForwardsPin' with no type [-fpermissive]

     ForwardsPin(FP);

                   ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:18:18: error: 'BP' is not a type

     BackwardsPin(BP);

                  ^~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:18:20: warning: ISO C++ forbids declaration of 'BackwardsPin' with no type [-fpermissive]

     BackwardsPin(BP);

                    ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:19:5: error: 'On' does not name a type

     On/OffPin(O/FP);

     ^~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:22:10: error: variable or field 'On' declared void

     void On/Off();

          ^~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:22:10: error: expected ';' at end of member declaration

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:22:12: error: expected unqualified-id before '/' token

     void On/Off();

            ^

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:26:9: error: expected ';' at end of member declaration

     int _O/FP;

         ^~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:26:11: error: expected unqualified-id before '/' token

     int _O/FP;

           ^

Test:2:21: error: no matching function for call to 'Motor::Motor(int)'

 Motor ForwardsPin(11);

                     ^

In file included from C:\Users\micahthetanker\Documents\Arduino\Test\Test.ino:1:0:

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note: candidate: Motor::Motor()

 class Motor

       ^~~~~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note:   candidate expects 0 arguments, 1 provided

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note: candidate: constexpr Motor::Motor(const Motor&)

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note:   no known conversion for argument 1 from 'int' to 'const Motor&'

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note: candidate: constexpr Motor::Motor(Motor&&)

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note:   no known conversion for argument 1 from 'int' to 'Motor&&'

Test:3:22: error: no matching function for call to 'Motor::Motor(int)'

 Motor BackwardsPin(10);

                      ^

In file included from C:\Users\micahthetanker\Documents\Arduino\Test\Test.ino:1:0:

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note: candidate: Motor::Motor()

 class Motor

       ^~~~~

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note:   candidate expects 0 arguments, 1 provided

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note: candidate: constexpr Motor::Motor(const Motor&)

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note:   no known conversion for argument 1 from 'int' to 'const Motor&'

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note: candidate: constexpr Motor::Motor(Motor&&)

C:\Users\micahthetanker\Documents\Arduino\libraries\Gearmotor-Driver-0.0.1/Gearmotor-Driver.h:11:7: note:   no known conversion for argument 1 from 'int' to 'Motor&&'

Test:4:9: error: expected initializer before '/' token

 Motor On/OffPin(9);

         ^

C:\Users\micahthetanker\Documents\Arduino\Test\Test.ino: In function 'void loop()':

Test:13:8: error: expected unqualified-id before '.' token

   Motor.Forward();

        ^

Test:15:8: error: expected unqualified-id before '.' token

   Motor.Stop();

        ^

Test:17:8: error: expected unqualified-id before '.' token

   Motor.Backward();

        ^

Test:19:8: error: expected unqualified-id before '.' token

   Motor.Stop();

        ^

exit status 1

no matching function for call to 'Motor::Motor(int)'



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I just can’t Figure it out!!
I have a feeling its one small mistake… like a single character…
But no luck…

Thanks in advance!

` Gearmotor-Driver_h`

You may find that the thingy thinks you are trying to subtract Driver_h from Gearmotor.

Again, illegal characters in a variable name.

Take a look at this :slightly_smiling_face: :upside_down_face:

Here’s trouble I see over and over…

Motor::On/OffPin(O/FP); // <<< ----- semicolon in wrong place for function!
{
  pinMode(BP, OUTPUT);
  _O/FP = O/FP;
}

-jim lee

Just a style note… (I) tend to put the things Mrs user needs to use at the top. Then shove all the other bits toward the end. With the protected & private stuff at the bottom.

-jim lee