Reputation: 15
When compiling my code, I'm receiving many different errors such as:
frame.h:5:48: error: expected identifier before '(' token
frame.h:5:17: error: variable or field 'writeFrame' declared void
frame.h:5:17: error: 'GifWriter' was not declared in this scope
frame.h:5:34: error: expected primary-expression before 'double'
These errors more or less apply for all the function parameters.
Here is the header file:
#ifndef frame_h
#define frame_h
void writeFrame(GifWriter* gptr, double delay, (std::vector<uint8_t>& frameOut), ImageData* image1ptr, struct Options mode, int frameNum, bool* runptr);
void runPRGM(ImageData* image1ptr, struct Options mode);
#endif
My .cpp file does include the required libraries and this .h file, and the two functions are declared in the same way. I'm certain the brackets and parentheses are parsed correctly. Other than the function definitions within the .cpp, these are the only instances of the functions' declarations. What could I potentially be doing wrong? I did read in some other thread that g++ conflicts with certain void functions as well but there wasn't much elaboration on that.
Upvotes: 0
Views: 49
Reputation: 87959
Change (std::vector<uint8_t>& frameOut)
to std::vector<uint8_t>& frameOut
.
Not sure why you felt the need to put the brackets there, and the first error message is telling you that's the problem.
Also note that you should write header files so that they are self-contained. This means that this header file should have #include <vector>
as well as having declarations for GifWriter
etc. These may be forward declarations if the circumstances are right.
So the header should look something like this
#ifndef frame_h
#define frame_h
#include <vector> // for vector
#include <cstdint> // for uint8_t
class GifWriter; // forward declarations
class ImageData;
struct Options;
void writeFrame(GifWriter* gptr, double delay, std::vector<uint8_t>& frameOut, ImageData* image1ptr, Options mode, int frameNum, bool* runptr);
void runPRGM(ImageData* image1ptr, Options mode);
#endif
Image assuming that GifWriter
, ImageData
and Options
are classes that you have written and therefore its safe to forward declare them. If not then you should include the header files for those classes here instead.
Upvotes: 3