I become creasy on a ")" error

Dear All,

I look on a existing library and I am trying to do the same.
Then my code is similar but when I compile, I can see that error:

In file included from /Users/pierrot/Documents/Arduino/libraries/Sim908/Sim908.cpp:2:
/Users/pierrot/Documents/Arduino/libraries/Sim908/Sim908.h:17: error: expected )' before '*' token /Users/pierrot/Documents/Arduino/libraries/Sim908/Sim908.cpp:4: error: expected )’ before ‘*’ token

I become “creasy” because I lool and looked when a ) is missing and I could not find and undertsand the error.

May I ask to help me?

Here is the code

Sim908_v6.ino
#include <SoftwareSerial.h>
#include <Sim908.h>

// GENERAK
#define DEBUG
int pinToPowerOnModule = 8;

// LED
int green = 12;
#define MSEC 500
#define MSEC_FAST 150

// SERIAL
int baud_rate = 9600;
#define RXPIN 2 
#define TXPIN 3

Sim908 sim908(new SoftwareSerial(RXPIN, TXPIN), baud_rate, pinToPowerOnModule);

void setup()
{
  pinMode(green, OUTPUT);
  
  Serial.begin(9600);

}


void loop()
{
  //sim908.blinkLed(green, 1, MSEC);

}

Here is my Sim908.h file

/*
  Sim908.h - Library 
*/

#ifndef Sim908_h
#define Sim908_h

#include "Arduino.h"


class Sim908{
	private:
		int _pinToPowerOnModule;
		//SoftwareSerial _cell;
		Stream* _cell;
	public:
		Sim908(SoftwareSerial* serial, int baud_rate, int pinToPowerOnModule);
		
		void blinkLed(int lPin, int nBlink, int msec);

};

#endif

and here is the last file, Sim908.cpp (I only copy the code which make problem

#include "Arduino.h"
#include "Sim908.h"

Sim908::Sim908(SoftwareSerial* serial, int baud_rate, int pinToPowerOnModule)
{
	pinMode(pinToPowerOnModule, OUTPUT);
	_pinToPowerOnModule = pinToPowerOnModule;
	_cell = serial;

};

Where is the problem with a ) ???

Many thank for your help!!

/Users/pierrot/Documents/Arduino/libraries/Sim908/Sim908.h:17: error: expected `)' before '*' token

So, what does line 17 of Sim908.h look like?

		Sim908(SoftwareSerial* serial, int baud_rate, int pinToPowerOnModule);

OK, so where is there a * token? Can you spot it?

The compiler is telling you that there is something wrong with that line. It doesn't recognize SoftwareSerial as anything, so it thinks that perhaps you've forgotten a ) before it.

Of course, adding a parentheses before the * is not the correct solution.

I'm hoping that you recognize what the correct solution is, given this explanation.

This line look strange

Sim908 sim908(new SoftwareSerial(RXPIN, TXPIN), baud_rate, pinToPowerOnModule);

...R

This line look strange

Why? That is no different from:

SoftwareSerial *pSS = new SoftwareSerial(RXPIN, TXPIN);
Sim908 sim908(pSS, baud_rate, pinToPowerOnModule);

PaulS:

This line look strange

Why? That is no different from:

SoftwareSerial *pSS = new SoftwareSerial(RXPIN, TXPIN);

Sim908 sim908(pSS, baud_rate, pinToPowerOnModule);

Ahhh.

I only do simple stuff ...

...R

Dear PaulS

Thank for your help.
In fact I compared my file my exemple file. I missed to add

#include <SoftwareSerial.h>

in the Sim908.h file.

Since the error message desapeared and I do have other error.

Was what you thouth about?

Cheers

I do have other error.

Feel free to post them, and the modified code.

Oups sorry, I wanted to write
I do not have other error. :slight_smile: :slight_smile:
Thank to you