2

I have searched through many posts on here and cannot seem to locate a solution to my problem. I am getting two errors when I try to compile my program, both of them are coming from one of my header files. Here are the errors:

Error 1 error C2146: syntax error : missing ';' before identifier 'datastore'

AND

Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

In my cpp file I have scope resolution operators and I don't have any squiggly red lines under anything. Also the program compiled ONCE and then I saved it and reopened the program and it gave me these errors. So I think I originally "tricked" the compiler or something weird. So any help would be awesome!

#ifndef INTERNET_H
#define INTERNET_H

#include <windows.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <sstream>
#include "Wininet.h"
#include "Internet.h"
#include "ForexPrices.h"
using namespace std;

class Internet
{
private:
    ForexPrices datastore;
    BOOL bResult;

    char *chPtr0, 
         *chPtr1, 
         *chPtr2; 

    DWORD dw1, 
          dw2, 
          dwIndex;

    HINTERNET hInet, hRequest;
    HINTERNET h_Inet;

     char ch_Buffer[4096], 
          ch_Line[256];

     std::ofstream of_OutFile;


public:
    Internet();
    void openFile();
    void internetCheckConnection();
    HINTERNET internetopen();
    HINTERNET internetconnect();    
    void internetclose();
    void closeFile();
    char* grabMargin();
    double grabDailyAverageLine();
    void setcurrency(char *currencyfiller1);
};

#endif
  • 2
    Is ForexPrices.h requiring inclusion of the header file you posted? These kinds of errors are typical of circular dependencies. – SleuthEye Feb 23 '15 at 01:47

1 Answers1

1

[error C2146: syntax error : missing ';' before identifier 'datastore'] is a hint that the class before 'datastore' is unknown, which leads to your next error.

[error C4430: missing type specifier - int assumed. Note: C++ does not support default-int] comes as a result of the first error. Because the compiler doesn't know what your ForexPrices class is, it is trying to use something else (I'm no expert on default-int). This is not supported and so you see this error instead.

For some reason your ForexPrices class is unknown. I see that you included the file above, ForexPrices.h. I would make sure that the name of your class is exactly the same in your header file as it is used here. Also make sure it isn't declared in a namespace that you haven't included. If so, you'll need another using statement or reference the class in the namespace (YourNamespace::ForexPrices). It's good practice not too always trust the "squigglies" I think. Visual studio can sometimes goof at least until your solution is fully parsed, but this is more of a problem on very large projects where parsing takes some time.

KiraBox
  • 69
  • 1
  • 10
  • I didn't declare the class in a namespace or atleast I didn't mean to. I am not even sure how to do that to be completely honest. So here is the weird thing. If I do //ForexPrices datastore, compile it, take away the // real quick, and recompile it compiles fine. I don't understand what is happening lol. I also noticed the compiler says "skipping... (no relevant changes detected) if that makes a difference. – Patrick Rosenthal Feb 26 '15 at 05:33
  • Does ForexPrices.h include this file as well? As SleuthEye mentioned above in the comment, your problem could be related to a circular dependency. The first answer [here](http://stackoverflow.com/questions/625799/resolve-circular-dependencies-in-c) might help you understand how to fix things if it is. – KiraBox Feb 27 '15 at 01:00