VS2010 IntelliSense says: CComPtr is not a template - c++

I have encountered a problem when I was trying to write a directshow-based livestream player as an ActiveX control.
I first created a MFC ActiveX control project with VS2010 (under VC++ category),
and attached a dialog on the control, then tested it with a simple html page.
So far it works well, but when I tried to add some directshow codes with CComPtr,
the compiler shows the following errors (I've also attached the line numbers and files):
29 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 37)
30 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 38)
31 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 44)
32 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 44)
33 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 47)
34 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 48)
35 IntelliSense: CComPtr is not a template (CIceBaseLivestreamPlayerCore.h, Line 49)
36 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 19)
37 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 20)
38 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 21)
39 IntelliSense: CComPtr is not a template (CIcePlayAndSaveAXCore.h, Line 22)
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 19)
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 20)
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 21)
Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (CIcePlayAndSaveAXCore.h, Line 22)
Error 25 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_vInfTee' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 27 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_fileWriter' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 28 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_AVIMux' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 26 error C2614: 'CIcePlayAndSaveAXCore' : illegal member initialization: 'm_aInfTee' is not a base or member (CIcePlayAndSaveAXCore.h, Line 9)
Error 12 error C2614: 'CIceBaseLivestreamPlayerCore' : illegal member initialization: 'm_pGraph' is not a base or member (CIceBaseLivestreamPlayerCore.h, Line 18)
Error 11 error C2614: 'CIceBaseLivestreamPlayerCore' : illegal member initialization: 'm_pControl' is not a base or member (CIceBaseLivestreamPlayerCore.h, Line 18)
Error 3 error C2238: unexpected token(s) preceding ';' (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 6 error C2238: unexpected token(s) preceding ';' (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 15 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 19)
Error 18 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 20)
Error 21 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 21)
Error 24 error C2238: unexpected token(s) preceding ';' (CIcePlayAndSaveAXCore.h, Line 22)
Error 1 error C2143: syntax error : missing ';' before '<' (CIceBaseLivestreamPlayerCore.h, Line 37)
Error 4 error C2143: syntax error : missing ';' before '<' (CIceBaseLivestreamPlayerCore.h, Line 38)
Error 13 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 19)
Error 16 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 20)
Error 19 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 21)
Error 22 error C2143: syntax error : missing ';' before '<' (CIcePlayAndSaveAXCore.h, Line 22)
Error 7 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 44)
Error 8 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 47)
Error 9 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 48)
Error 10 error C2061: syntax error : identifier 'CComPtr' (CIceBaseLivestreamPlayerCore.h, Line 49)
And all these errors seem to specify that there is something weird with the CComPtr,
but I cannot figure out what's wrong.
I've added two header files in the bottom of my stdafx.h as following:
#include <streams.h>
#include <atlbase.h>
And I'll list part of my CIceBaseLivestreamPlayerCore.h and CIcePlayAndSaveAXCore.h as below, all the involved lines in the above errors are all included.
CIceBaseLivestreamPlayerCore.h:
#pragma once
#include "stdafx.h"
class CIceBaseLivestreamPlayerCore
{
...
15 CIceBaseLivestreamPlayerCore():
16 ..., m_pGraph(NULL), m_pControl(NULL),
17 ...
18 { ; }
...
37 CComPtr<IGraphBuilder> m_pGraph;
38 CComPtr<IMediaControl> m_pControl;
...
44 HRESULT ConnectFilters(CComPtr<IBaseFilter> pIn, CComPtr<IBaseFilter> pOut, const AM_MEDIA_TYPE& mType);
...
47 HRESULT MatchPin(CComPtr<IPin>, PIN_DIRECTION, BOOL, BOOL*);
48 HRESULT IsPinConnected(CComPtr<IPin>, BOOL*);
49 HRESULT IsPinDirection(CComPtr<IPin>, PIN_DIRECTION, BOOL*);
};
CIcePlayAndSaveAXCore.h:
#pragma once
#include "CIceBaseLivestreamPlayerCore.h"
class CIcePlayAndSaveAXCore : public CIceBaseLivestreamPlayerCore
{
...
7 CIcePlayAndSaveAXCore() :
8 m_AVIMux(NULL), m_fileWriter(NULL), m_aInfTee(NULL), m_vInfTee(NULL)
9 { ; }
...
19 CComPtr<IBaseFilter> m_AVIMux;
20 CComPtr<IBaseFilter> m_fileWriter;
21 CComPtr<IBaseFilter> m_aInfTee;
22 CComPtr<IBaseFilter> m_vInfTee;
};
Additional dependencies of my project is "strmbasd.lib;winmm.lib;uuid.lib;".
That's all.. Hope someone can give me the answer of how to solve it,
or just gives me any advice or suggestion as a direction of what I should do.
Any help is appreciated.
And this is my first time to post an English question (I'm not a native speaker though..),
so please let me know if I've anything lost or done something wrong as asking a question.
Thanks a lot. :)

After many times of trying I finally found the problem and got it solved.
I think I should put the result here, for there might be someone who has the same problem,
and is not knowing how to solve it like I was. I don't know if it's an etiquette offense of stackoverflow to answer my own question, so I will left this answer unaccepted.
As I've said, I've put #define <atlbase.h> into the bottom of my stdafx.h.
But because I'm making a MFC ActiveX control project, the IDE (VS 2010) auto generates a #define statement into my stdafx.h, which is #define _ATL_NO_AUTOMATIC_NAMESPACE.
And when we use #include <atlbase.h> in ordinary times, the compiler will perform using namespace ATL by default, but this #define _ATL_NO_AUTOMATIC_NAMESPACE statement cancels this behavior, which then caused the naming conflict that my compiler had said.
So, in this case, just use ATL::CComPtr for declarations or directly use using ATL::CComPtr statement in which CComPtr appears, and this compilation error will be eliminated.

Related

IntelliSense: identifier "IDXGISwapChain1" is undefined

I have saved a captured frame using NVIDIA Nsight and when I open the saved solution file I get the following itellisense error:
IntelliSense: identifier "IDXGISwapChain1" is undefined [..]
I have made no changes to the solution.
I also get the follow errors when building (using VS2013):
Error 1 error C2143: syntax error : missing ';' before '' c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 3 error C2143: syntax error : missing ';' before '' c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 5 error C2143: syntax error : missing ';' before '' c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 7 error C2143: syntax error : missing ';' before '' c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 9 error C2143: syntax error : missing ';' before '' c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 10 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 11 error C2146: syntax error : missing ';' before identifier 'DXGI_SWAP_CHAIN_DESC1_temp_1' C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 88 1 build11__2015_06_20__15_15_15
Error 12 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 88 1 build11__2015_06_20__15_15_15
Error 13 error C2065: 'DXGI_SWAP_CHAIN_DESC1_temp_1' : undeclared identifier C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 88 1 build11__2015_06_20__15_15_15
Error 14 error C2146: syntax error : missing ';' before identifier 'DXGI_SWAP_CHAIN_FULLSCREEN_DESC_temp_1' C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 89 1 build11__2015_06_20__15_15_15
Error 15 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 89 1 build11__2015_06_20__15_15_15
Error 16 error C2065: 'DXGI_SWAP_CHAIN_FULLSCREEN_DESC_temp_1' : undeclared identifier C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 89 1 build11__2015_06_20__15_15_15
Error 17 error C2065: 'IDXGIFactory2' : undeclared identifier C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 90 1 build11__2015_06_20__15_15_15
Error 18 error C2059: syntax error : ')' C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 90 1 build11__2015_06_20__15_15_15
Error 19 error C2227: left of '->Release' must point to class/struct/union/generic type C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 727 1 build11__2015_06_20__15_15_15
Error 20 error C2143: syntax error : missing ';' before '' C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 771 1 build11__2015_06_20__15_15_15
Error 21 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 771 1 build11__2015_06_20__15_15_15
Error 22 error C2086: 'int pIDXGISwapChain1_uidof_68' : redefinition C:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources00.cpp 771 1 build11__2015_06_20__15_15_15
Error 23 error C2143: syntax error : missing ';' before '' c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
Error 24 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users[...]\documents\nvidia nsight\captures\build11__2015_06_20__15_15_15\Resources.h 27 1 build11__2015_06_20__15_15_15
25 IntelliSense: identifier "IDXGISwapChain1" is undefined c:\Users[...]\Documents\NVIDIA Nsight\Captures\build11__2015_06_20__15_15_15\Resources.h 27 8 build11__2015_06_20__15_15_15
It is a bug in the way Nsight serializes the frame. The solution is to add
#include <dxgi1_2.h>
to resources.h
and, in my case, change the second parameter to CreateSwapChainForHwnd from NULL to hWindow_000D060E in the Resources00.cpp file.

Declare function that returns a string in header file

How do you declare a function that returns a string in the header file, so it can be used by other *.cpp files.
For example the code bellow does not compile with the following errors:
Source.h
#pragma once
#include <string>
string MyFunc();
Source.cpp
#include "stdafx.h"
#include "Source.h"
using namespace std;
string MyFunc()
{
string str;
return str;
}
Errors
Error 1 error C2146: syntax error : missing ';' before identifier 'MyFunc' 4 1
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 4 1
Error 3 error C2872: 'string' : ambiguous symbol 5 1
Error 4 error C2146: syntax error : missing ';' before identifier 'MyFunc' 5 1
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 5 1
Error 6 error C2086: 'int string' : redefinition 5 1
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 6 1
Error 8 error C2872: 'string' : ambiguous symbol 7 1
Error 9 error C2146: syntax error : missing ';' before identifier 'str' 7 1
Error 10 error C2065: 'str' : undeclared identifier 7 1
Error 11 error C2065: 'str' : undeclared identifier 8 1
If I replace string with char*, it compiles with no errors.
What about:
std::string MyFunc();
You'll need to add the std:: prefix unless you use the namespace. Generally you might as well prefix it to avoid conflict with your own classes.

Getting string compile errors in visual studio using the boost string lib

i am trying to make a program that reads from an ini file but in Visual Studio I keep getting compile errors about string identifiers and semicolons in the wrong place. I am not very good at C++ so it's most likely something really simple, but any way here is the code and error list.
INI.h
#ifndef INI_H
#define INI_H
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
string INIreader(const string&, const string&);
#endif
INI_readnwrite.cpp
#include "INI.h"
using boost::property_tree::ptree;
string INIreader(const string& section, const string& name)
{
ptree pt;
read_ini("GameSettings.ini", pt);
string value = pt.get<string>("section.name");
return value;
}
mainCode.cpp
#include "INI.h"
using namespace std;
int main()
{
string sec = "gameSettings";
string val = "resXY";
cout << INIreader(sec, val);
}
And here is the error list
error// file// line//
error C2872: 'string' : ambiguous symbol maincode.cpp 18
error C2146: syntax error : missing ';' before identifier 'sec' maincode.cpp 18
error C2065: 'sec' : undeclared identifier maincode.cpp 18
error C2872: 'string' : ambiguous symbol maincode.cpp 19
error C2146: syntax error : missing ';' before identifier 'val' maincode.cpp 19
error C2065: 'val' : undeclared identifier maincode.cpp 19
error C2065: 'val' : undeclared identifier maincode.cpp 20
error C2065: 'sec' : undeclared identifier maincode.cpp 20
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini_readnwrite.cpp 6
error C2872: 'string' : ambiguous symbol ini_readnwrite.cpp 6
error C2146: syntax error : missing ';' before identifier 'INIreader' ini_readnwrite.cpp 6
error C2143: syntax error : missing ',' before '&' ini_readnwrite.cpp 6
error C2086: 'int string' : redefinition ini_readnwrite.cpp 6
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini_readnwrite.cpp 7
error C2974: 'boost::property_tree::basic_ptree<std::string,std::string,std::less<Key>>::get' : invalid template argument for 'Type', type expected ini_readnwrite.cpp 10
error C2974: 'boost::property_tree::basic_ptree<std::string,std::string,std::less<Key>>::get' : invalid template argument for 'Ch', type expected ini_readnwrite.cpp 10
error C2146: syntax error : missing ';' before identifier 'value' ini_readnwrite.cpp 10
error C2065: 'value' : undeclared identifier ini_readnwrite.cpp 10
error C2065: 'value' : undeclared identifier ini_readnwrite.cpp 11
IntelliSense: identifier "string" is undefined INI.h 9
IntelliSense: identifier "string" is undefined INI.h 9
IntelliSense: identifier "string" is undefined INI.h 9
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini.h 9
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ini.h 9
error C2146: syntax error : missing ';' before identifier 'INIreader' ini.h 9
error C2146: syntax error : missing ';' before identifier 'INIreader' ini.h 9
error C2143: syntax error : missing ',' before '&' ini.h 9
error C2143: syntax error : missing ',' before '&' ini.h 9
Thanks.
You need to use the fully qualified name when you attempt to use std::string in your header file:
std::string INIreader(const std::string&, const std::string&);
And do the same thing in INI_readnwrite.cpp, or add a "using" directive like you did in the other .cpp file:
using boost::property_tree::ptree;
using namespace std;

Function prototypes and enum

I've declared a global enum type in my program and want various functions within my program to return instances of the enum type. Here is my declaration:
#ifndef GLOBAL_H_
#define GLOBAL_H_
#include <SDL.h>
#include "LTexture.h"
#include "LButton.h"
#include "Initializationetc.h"
enum LButtonSprite
{
BUTTON_SPRITE_MOUSE_OUT = 0,
BUTTON_SPRITE_MOUSE_OVER_MOTION = 1,
BUTTON_SPRITE_MOUSE_DOWN = 2,
BUTTON_SPRITE_TOTAL = 2
};
...
However, when I go try and build a function that returns "LButtonSprite" the following happens:
#ifndef LBUTTON_H
#define LBUTTON_H
#include <SDL.h>
#include "Global.h"
class LButton
{
public:
//Initializes internal variables
LButton();
//Sets top left position
void setPosition(int x, int y);
//Handles mouse event
void handleEvent(SDL_Event* e);
//Shows button sprite
void render();
LButtonSprite getCurrSprite();//here
private:
//Button Position
SDL_Point mPosition;
//Button Sprite
LButtonSprite mCurrentSprite; //and here.
};
#endif
It seems as if the Visual Studio is mistaking the function prototype LButtonSprite getCurrSprite(); for a declaration of a variable called getCurrSprite() of type LButtonSprite. The colour coding provided by VS (as seen above) seems to confirm this suspicion. Return types are blue, but LButtonSprite is light blue which is the colour reserved for variables.
The problem isn't just cosmetic unfortunately. I'm getting a bunch ofC4430: missing type specifier - int assumed. Note: C++ does not support default-int. I've added comments to the code at the lines where the error is occurring. The complete error log is included at the end of the post.
How can I correct this mistake?
Error log:
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\global.h 34 1 SDL2_tutorials
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 4 error C2146: syntax error : missing ';' before identifier 'mCurrentSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 10 error C2146: syntax error : missing ';' before identifier 'mCurrentSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 19 error C2146: syntax error : missing ';' before identifier 'mCurrentSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 29 1 SDL2_tutorials
Error 1 error C2146: syntax error : missing ';' before identifier 'getCurrSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 7 error C2146: syntax error : missing ';' before identifier 'getCurrSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Error 16 error C2146: syntax error : missing ';' before identifier 'getCurrSprite' c:\users\adam\documents\visual studio 2013\projects\sdl2_tutorials\sdl2_tutorials\lbutton.h 22 1 SDL2_tutorials
Return types are blue
No – keywords are blue. Why else would enum, class, public and private be blue? Return types have no special syntax highlighting. The problem in your code is completely unrelated:
#ifndef GLOBAL_H_
#define GLOBAL_H_
#include <SDL.h>
#include "LTexture.h"
#include "LButton.h"
The last line includes (and thus declares) the LButton class, before you define your enum. Remove that line from the file, or define the enum before.
I'm assuming you use VS2012. In VS2012, all user defined types(return values are no exception) are colored light blue. Dark blue are reserved words.
The reason why your function's return type is light blue is because the return type is a user defined type.
From your code I see you have #include "LButton.h" probably containing the definition of class LButton before declaration of the enum LButtonSprite, therefore the IDE and the compiler does not see the LButtonSprite declared in the LButton, hence the wrong coloring.
You should include it the other way around, LButtonSprite.h into LButton.h

How to find the "real" error?

I am having an enormous amount of errors showing up in the error list of the program, but none of the ones listed seem to be "real" errors. Some of the lines are red and then when I go to highlight over them the error disappears. I just can't seem to find where my error really is. What is the best process to go through to find my mistake?
Below is the error list in case that is helpful.
Error 38 error C1004: unexpected end-of-file found 85
Error 68 error C1004: unexpected end-of-file found 42
Error 63 error C1903: unable to recover from previous error(s); stopping compilation 72
Error 66 error C2059: syntax error : ')' 42
Error 2 error C2059: syntax error : '>' 80
Error 40 error C2059: syntax error : '>' 80
Error 65 error C2059: syntax error : '>' 42
Error 20 error C2065: '_Ptr_cerr' : undeclared identifier 27
Error 16 error C2065: '_Ptr_cin' : undeclared identifier 25
Error 22 error C2065: '_Ptr_clog' : undeclared identifier 28
Error 18 error C2065: '_Ptr_cout' : undeclared identifier 26
Error 28 error C2065: '_Ptr_wcerr' : undeclared identifier 32
Error 24 error C2065: '_Ptr_wcin' : undeclared identifier 30
Error 30 error C2065: '_Ptr_wclog' : undeclared identifier 33
Error 26 error C2065: '_Ptr_wcout' : undeclared identifier 31
Error 4 error C2065: 'faction' : undeclared identifier 84
Error 42 error C2065: 'faction' : undeclared identifier 84
Error 64 error C2065: 'Faction' : undeclared identifier 42
Error 13 error C2065: 'socialite' : undeclared identifier 100
Error 51 error C2065: 'socialite' : undeclared identifier 100
Error 1 error C2065: 'Socialite' : undeclared identifier 80
Error 12 error C2065: 'Socialite' : undeclared identifier 100
Error 39 error C2065: 'Socialite' : undeclared identifier 80
Error 50 error C2065: 'Socialite' : undeclared identifier 100
Error 8 error C2065: 'textWriter' : undeclared identifier 82
Error 46 error C2065: 'textWriter' : undeclared identifier 82
Error 6 error C2143: syntax error : missing ',' before ')' 84
Error 10 error C2143: syntax error : missing ',' before ')' 82
Error 14 error C2143: syntax error : missing ',' before ')' 100
Error 44 error C2143: syntax error : missing ',' before ')' 84
Error 48 error C2143: syntax error : missing ',' before ')' 82
Error 52 error C2143: syntax error : missing ',' before ')' 100
Error 17 error C2143: syntax error : missing ',' before ';' 25
Error 19 error C2143: syntax error : missing ',' before ';' 26
Error 21 error C2143: syntax error : missing ',' before ';' 27
Error 23 error C2143: syntax error : missing ',' before ';' 28
Error 25 error C2143: syntax error : missing ',' before ';' 30
Error 27 error C2143: syntax error : missing ',' before ';' 31
Error 29 error C2143: syntax error : missing ',' before ';' 32
Error 31 error C2143: syntax error : missing ',' before ';' 33
Error 7 error C2143: syntax error : missing ';' before '{' 32
Error 15 error C2143: syntax error : missing ';' before '{' 10
Error 32 error C2143: syntax error : missing ';' before '{' 36
Error 35 error C2143: syntax error : missing ';' before '{' 27
Error 45 error C2143: syntax error : missing ';' before '{' 32
Error 54 error C2143: syntax error : missing ';' before '{' 34
Error 57 error C2143: syntax error : missing ';' before '{' 48
Error 60 error C2143: syntax error : missing ';' before '{' 61
Error 3 error C2143: syntax error : missing ';' before '}' 82
Error 11 error C2143: syntax error : missing ';' before '}' 98
Error 33 error C2143: syntax error : missing ';' before '}' 42
Error 34 error C2143: syntax error : missing ';' before '}' 45
Error 36 error C2143: syntax error : missing ';' before '}' 83
Error 37 error C2143: syntax error : missing ';' before '}' 85
Error 41 error C2143: syntax error : missing ';' before '}' 82
Error 49 error C2143: syntax error : missing ';' before '}' 98
Error 55 error C2143: syntax error : missing ';' before '}' 43
Error 58 error C2143: syntax error : missing ';' before '}' 57
Error 61 error C2143: syntax error : missing ';' before '}' 69
Error 67 error C2143: syntax error : missing ';' before '}' 42
Error 5 error C2275: 'Faction' : illegal use of this type as an expression 84
Error 43 error C2275: 'Faction' : illegal use of this type as an expression 84
Error 9 error C2275: 'std::ofstream' : illegal use of this type as an expression 82
Error 47 error C2275: 'std::ofstream' : illegal use of this type as an expression 82
Error 53 error C2653: 'Socialite' : is not a class or namespace name 33
Error 56 error C2653: 'Socialite' : is not a class or namespace name 46
Error 59 error C2653: 'Socialite' : is not a class or namespace name 60
Error 62 error C2653: 'Socialite' : is not a class or namespace name 72
Probably a missing ; after the closing } of a class / struct. Could you post some code?
UPDATE: The code compiles now on my gcc. The problem I found is that you have a circular dependency between your classes. So solve this, forward declare some of them in the headers. I added class Faction; before class Socialite in Socialite.h and class Socialite; before class Faction in Faction.h.
Unexpected end of file is usually that you are missing a closing "something", such as a bracket } or parenthesis )
It's either a missing #endif or a ; at the end of a type definition or possibly a missing } at the end of a function.
Start with the first error reported. Often it's the cause of a lot of the subsequent problems because the first error causes the parser to be out of sync with the rest of the code.
In C++, long cascades of errors are often caused by an undeclared type (did you forget an include file?) or by a missing ; after a class or struct definition.
Consider:
Foobar fb; // Declare an instance of Foobar.
If Foobar hasn't been declared yet (perhaps because you forgot to include "foobar.h"), then the compiler might think you're trying to declare a variable named Foobar with a default type of int. From there, it sees the fb and gets all confused.
Or consider:
struct Foobar {
int x;
int y;
}
int blah = 0;
Without the ; after the struct definition, the parser thinks you're trying to declare an instance of Foobar named int, which isn't allowed since int is a reserved keyword. And everything after that looks like gobbledegook to the compiler.
One trick is to temporarily #if 0-out all the code after the line with the first reported error, as that will reduce the noise until you isolate the original problem.
If you look at the "Error List" window (View > Error List) it can be really hard to figure out where the errors originate. Luckily, there's another way:
Open the "Output" window (Debug > Windows > Output)
Compile and build
Start at the top of the "Output" window and work your way down the compiler/linker output text until you come to the first line that says "error"
This will usually lead you right to the problem.