I'm following a Packt tutorial regarding CSV table entry. The tutorial requires that I a) create a new Actor class, b) name it TestCustomData, and c) replace the contents of the newly-generated TestCustomData.h with the following code:
#pragma once
#include "TestCustomData.generated.h"
USTRUCT(BlueprintType)
struct FTestCustomData : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
UPROPERTY( BlueprintReadOnly, Category = "TestCustomData" )
int32 SomeNumber;
UPROPERTY( BlueprintReadOnly, Category = "TestCustomData" )
FString SomeString;
};
However, the TestCustomData file fails to compile, outputting the following log:
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(5) : error C2504: 'FTableRowBase': base class undefined
Info Compiling game modules for hot reload
Info Parsing headers for UE4_ProjectRPGEditor
Info Running UnrealHeaderTool "F:\Unreal\UE4 Assignments\UE4_ProjectRPG\UE4_ProjectRPG.uproject" "F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Intermediate\Build\Win64\UE4_ProjectRPGEditor\Development\UE4_ProjectRPGEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Info Reflection code generated for UE4_ProjectRPGEditor in 3.4146568 seconds
Info Performing 4 actions (4 in parallel)
Info TestCustomData.cpp
Info UE4_ProjectRPG.generated.cpp
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(6) : error C3646: 'Super': unknown override specifier
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(5) : error C2504: 'FTableRowBase': base class undefined
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(6) : error C3646: 'Super': unknown override specifier
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Info ERROR: UBT ERROR: Failed to produce item: F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Binaries\Win64\UE4Editor-UE4_ProjectRPG-3031.dll
Info Total build time: 6.88 seconds (Local executor: 0.00 seconds)
I'm fairly new to StackOverflow and C++ in UE4, and any help would be appreciated. Any feedback to improve my question is also welcome! Thanks in advance for your help.
I was stuck at the same spot and this fixed it:
I named the Asset "MyActor2" and the Strucure "ThisNewStructure" so there are some little differences...
I think it was basicly including the Datatable.h and the "public:" that did the trick.
Header File:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Engine/DataTable.h"
#include "MyActor2.generated.h"
USTRUCT(BlueprintType)
struct FThisNewStructure : public FTableRowBase
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
int32 SomeNumber;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
FString SomeString;
};
cpp:
#include "MyActor2.h"
Then it compiles successful.
I had to do some closing/reopening of VS & UE for the Editor to know about the new structure.
It may be a little late, but I just ran into this myself. Sometimes you'll have an include that automatically grabs the FTableRowBase, but sometimes a class doesn't have a header that calls back to it. In that case:
#pragma once
#include "Engine/DataTable.h"//this is where FTableRowBase is declared.
#include "TestCustomData.generated.h"
struct FFoo : FTableRowBase
{
GENERATED_USTRUCT_BODY()
public:
the rest of your class...
I hope this helps! :D
Thanks for the help, I was working through the same problem in the same tutorial. Apparently you didn't need to rename TestCustomData to MyActor2, you just needed to add the line "public:" after the "GENERATED_USTRUCT_BODY()".
Related
I modified my project and after compiling there pop up some weird error.
#ifndef BART_RAY_TRACER_MESH_H
#define BART_RAY_TRACER_MESH_H
#include <vector>
#include "assert.h"
#include "vec3f.h"
class Triangle;
class Mesh {
public:
uint32_t nverts;
bool _is_static;
vec3f *verts;
vec3f *_verts_world;
Material material;
// 2 error occurs at the line below
Matrix4x4 _trans_local_to_world; // '_trans_local_to_world': unknown override specifier & missing type specifier - int assumed. Note: C++ does not support default-int
Matrix4x4 _trans_local_to_world_inv;
TransformHierarchy *_trans_hierarchy;
std::vector<Triangle* > triangles;
// ...
};
#endif
When I change the order of the declaration a little bit, the error always occurs the line after Material material, but with different message:
#ifndef BART_RAY_TRACER_MESH_H
#define BART_RAY_TRACER_MESH_H
#include <vector>
#include "assert.h"
#include "vec3f.h"
class Triangle;
class Mesh {
public:
uint32_t nverts;
bool _is_static;
vec3f *verts;
vec3f *_verts_world;
Material material;
// 2 error occurs at the line below
TransformHierarchy *_trans_hierarchy; // error C2143: syntax error: missing ';' before '*' & error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Matrix4x4 _trans_local_to_world;
Matrix4x4 _trans_local_to_world_inv;
std::vector<Triangle* > triangles;
// ...
};
#endif
I've searched for similar questions on SO but none seems useful.
I've checked my vec3f, Triangle class definition in case there are missing semicolons but I can't find any.
Can any one help?
This is just another Microsoft cock-up. Here it is in essence:
class C
{
x y ;
} ;
If you submit this to a sensible compiler like g++, it gives you a helpful error message:
3:2: error: 'x' does not name a type
MSVC, on the other hand, comes up with this gibberish:
(3): error C3646: 'y': unknown override specifier
(3): error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
With this key, you can decrypt Microsoft's error message into:
error: 'Matrix4x4' does not name a type
The error is most likely because that TransformHierarchy and Matrix4x4 are not defined.
If they are not defined in "assert.h" and "vec3f.h", this should be the case.
Forward declaration is enough only when you use the reference types and/or pointer types only. Therefore, to forward declare Triangle is OK. But forward declare Triangle does not mean your shape.h is processed. Neither does your material.h which is included in shape.h.
Therefore, all names in material.h is not visible from this code.
TransformHierarchy and Matrix4x4 are not recognized by the compiler.
Many of the compliers will complain with words similar to "missing type specifier - int assumed"
In my case, it was found that a header file had the following directives for a class [ie, myComboBoxData]
#ifndef __COMBOBOXDATA__
#define __COMBOBOXDATA__
// ...
class myComboBoxData
{
// ...
}
#endif
As another class below tried to use myComboBoxData class
class TypeDlg : public CDialog
{
myComboBoxData cbRow,cbCol;
// ...
}
the error message popped up as above:
"error C3646: 'cbRow': unknown override specifier".
Solution:
The problem was the directive name (__COMBOBOXDATA__) was already used by OTHER header.
Thus, make sure to use some other name like (__myCOMBOBOXDATA__).
I'm working on a little C++ WinAPI wrapper. I'd like to create my own window and append my own controls to it.
I created 2 classes : Window and Control.
The problem is that I struggle to deal with the multiple header files, because the class Control needs the class Window and vice versa. When I compile my code, I get many errors..
Here are my files :
globals.h :
// globals.h
// I need this file to define a few constants and to include the main headers needed by my classes
#ifndef GLOBALS_H
#define GLOBALS_H
#include <windows.h>
#include <iostream>
#include <vector>
#include "window.h"
#define SOME_GLOBAL_CONSTANT 1
#endif
window.h :
// window.h
#ifndef WINDOW_H
#define WINDOW_H
#include "globals.h"
#include "control.h"
class Window
{
public:
Window(RECT windowRect);
virtual ~Window();
void appendChild(Control* child);
private:
RECT m_windowRect;
Control m_staticBackground;
std::vector<Control*> m_children;
};
#endif
window.cpp :
// window.cpp
#include "window.h"
Window::Window(RECT windowRect) : m_windowRect(windowRect)
{
std::cout << SOME_GLOBAL_CONSTANT << std::endl;
}
Window::~Window()
{
m_children.clear();
}
void Window::appendChild(Control* child)
{
m_children.push_back(child);
}
control.h :
// control.h
#ifndef CONTROL_H
#define CONTROL_H
#include "globals.h"
class Control
{
public:
Control(Window* parentWindow);
virtual ~Control();
private:
RECT m_controlRect;
Window* m_parentWindow;
};
#endif
control.cpp :
// control.cpp
#include "control.h"
Control::Control(Window* parentWindow) : m_controlRect({}), m_parentWindow(parentWindow)
{
std::cout << SOME_GLOBAL_CONSTANT << std::endl;
}
Control::~Control()
{}
And finally, main.cpp :
#include "globals.h"
class MyCustomControl : public Control
{
public:
MyCustomControl(Window* parentWindow) : Control(parentWindow)
{}
~MyCustomControl()
{}
};
class MyWindow : public Window
{
public:
MyWindow(RECT windowRect) : Window(windowRect)
{
kid1 = new MyCustomControl(this);
appendChild(kid1);
}
~MyWindow()
{
delete kid1;
}
private:
MyCustomControl* kid1;
};
int main()
{
MyWindow appWindow;
std::cout << SOME_GLOBAL_CONSTANT << std::endl;
return 0;
}
Here are all the compilation errors I get :
1>------ Build started: Project: include, Configuration: Debug Win32 ------
1>window.cpp
1>d:\visual studio 2017\projects\include\include\control.h(9): error C2061: syntax error: identifier 'Window'
1>d:\visual studio 2017\projects\include\include\control.h(14): error C2143: syntax error: missing ';' before '*'
1>d:\visual studio 2017\projects\include\include\control.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio 2017\projects\include\include\control.h(14): error C2238: unexpected token(s) preceding ';'
1>main.cpp
1>d:\visual studio 2017\projects\include\include\control.h(9): error C2061: syntax error: identifier 'Window'
1>d:\visual studio 2017\projects\include\include\control.h(14): error C2143: syntax error: missing ';' before '*'
1>d:\visual studio 2017\projects\include\include\control.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio 2017\projects\include\include\control.h(14): error C2238: unexpected token(s) preceding ';'
1>d:\visual studio 2017\projects\include\include\main.cpp(8): error C2664: 'Control::Control(const Control &)': cannot convert argument 1 from 'Window *' to 'const Control &'
1>d:\visual studio 2017\projects\include\include\main.cpp(8): note: Reason: cannot convert from 'Window *' to 'const Control'
1>d:\visual studio 2017\projects\include\include\main.cpp(8): note: No constructor could take the source type, or constructor overload resolution was ambiguous
1>d:\visual studio 2017\projects\include\include\main.cpp(32): error C2512: 'MyWindow': no appropriate default constructor available
1>d:\visual studio 2017\projects\include\include\main.cpp(13): note: see declaration of 'MyWindow'
1>control.cpp
1>d:\visual studio 2017\projects\include\include\window.h(13): error C2061: syntax error: identifier 'Control'
1>d:\visual studio 2017\projects\include\include\window.h(17): error C3646: 'm_staticBackground': unknown override specifier
1>d:\visual studio 2017\projects\include\include\window.h(17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio 2017\projects\include\include\window.h(18): error C2065: 'Control': undeclared identifier
1>d:\visual studio 2017\projects\include\include\window.h(18): error C2059: syntax error: '>'
1>d:\visual studio 2017\projects\include\include\window.h(18): error C2976: 'std::vector': too few template arguments
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\vector(700): note: see declaration of 'std::vector'
1>Generating Code...
1>Done building project "include.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any help would be greatly appreciated.
Thank you in advance,
winapiwrapper.
Edit: I have also read this thread, but I couldn't solve my problem.
Welcome to programming. Strike down one error message and two shall take its place.
Well... Not really. What's happening is as you resolve one error, this reveals the errors that the precious errors were hiding.
First a PSA:
Don't write much code without compiling and testing. This way you have a smaller amount of code you need to check when something goes wrong. Start with a main function. Make sure it builds. Add the headers you need. Make sure it builds. Write a function for main to call. Make sure it builds. Repeat until program is finished. Trying to add too much all at once results in cascading storms of errors like you have experienced here.
Global include header files are usually a sucker bet. They often lead you into problems like the circular dependency you have here and make files include everything even when they don't have to. This can slow down build times.
Next, read the following link before continuing: Resolve header include circular dependencies
Now on with the answer:
window.h includes control.h. control .h includes window.h though global.h. This results in the Chicken and egg problem discussed in the above link. One of the headers is going to be included before the other and not be able to find the contents of the other file. Fortunately control.h only needs a reference to Window, not the whole thing, and this can be satisfied with a forward declaration and removing the global include file.
I'm not going to demonstrate cleaning this up. The process is well documented in the link.
This exposes hydra head number 2: Window contains Control m_staticBackground and does not explicitly initialize it. This results in the compiler hunting around for a default constructor for Control, something that does not exist.
Solution: Explicitly initialize m_staticBackground
Window::Window(RECT windowRect) : m_windowRect(windowRect),
m_staticBackground(this)
{
std::cout << SOME_GLOBAL_CONSTANT << std::endl;
}
BIG Mother Freaking note here: m_staticBackground(this) is dodgy as hell. this has not been fully constructed yet, so if you do more than simply store it in Control::Control (which is all you are currently doing) very bad, unpredictable things can happen. Do not use parentWindow or m_parentWindow inside the body of the Control constructor. If possible find a better, safer, way to do this. If not possible, document it with DO NOT USE messages to remind your future self or anyone else looking at the code not to use them.
Once this has been fixed you get to
MyWindow appWindow;
over in main. MyWindow's constructor requires a RECT you don't currently have a RECT to provide, so I'll stop here.
Move "window.h" from globals.h to controls.cpp. And put class Window; before class Controls { in controls.h. This is called forward declaration.
You even do not need window.h in controls.cpp, you can move it directly to your main.cpp.
I was implementing boost::intrusive for one of my project on visual C++ 2008 and i stumbled upon a problem. i am using splay hooks for splay_multiset containers. I have defined splay hook publically under MyClass (code below).
#include <boost/intrusive/unordered_set.hpp>
#include <boost/intrusive/splay_set.hpp>
#include <iostream>
using namespace boost::intrusive;
class MyClass
{
int int_;
public:
MyClass(int i)
: int_(i)
{}
splay_set_member_hook<link_mode<normal_link> > memberSplayHook;
//**OPTION-1**
//PROBLEM CODE SEGMENT ++
//typedef member_hook<MyClass, splay_set_member_hook<link_mode<normal_link> >, &MyClass::memberSplayHook> MemberOption;
//typedef splay_multiset<MyClass, MemberOption> MemberMultiSet;
//PROBLEM CODE SEGMENT --
MemberMultiSet mmset;
};
//**OPTION-2**
//WORKING CODE SEGMENT ++
typedef member_hook<MyClass, splay_set_member_hook<link_mode<normal_link> >, &MyClass::memberSplayHook> MemberOption;
typedef splay_multiset<MyClass, MemberOption> MemberMultiSet;
//WORKING CODE SEGMENT --
int main()
{
return 0;
}
The problem is, to use splay_multiset, whatever option i choose (either option-1 or 2, mention in code), in both cases i see compilation errors.
When Option-1 is enabled (option-2 is commented), i see errors below:
1>d:\projects\sampleproject\sample.cpp(21) : error C2327: 'MyClass::memberSplayHook' : is not a type name, static, or enumerator
1>d:\projects\sampleproject\sample.cpp(21) : error C2065: 'memberSplayHook' : undeclared identifier
1>d:\projects\sampleproject\sample.cpp(22) : error C3203: 'member_hook' : unspecialized class template can't be used as a template argument for template parameter 'O1', expected a real type
While, when Option-2 is enabled (option-1 is commented out), i dont see undeclared identifier error msg as these errors coming with option-1. But i do see errors like below (which are obvious).
1>d:\projects\sampleproject\sample.cpp(25) : error C2146: syntax error : missing ';' before identifier 'mmset'
1>d:\projects\sampleproject\sample.cpp(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
My question is why i am getting error in first case? What can i do to get pass this issue?
Boost member hooks have (always?) been broken, since they don't compile with Visual C++.
I don't have a VS at hand to check for the precise error message so I might be wrong (but reading 'member hooks' and 'Visual C++' always triggers 'there's a problem'-mode), but do try to check this:
http://permalink.gmane.org/gmane.comp.lib.boost.user/56875
EDIT: Don't take the headline literally -- the same applies to Visual C++ 2010 and 2012. All my member hooks use this workaround; at some point I might even try to understand what it does, or more importantly, how to package it into a more comfortable setup for less "I need to find a previous implementation of this workaround so I can copy-and-modify it"...
I need to refactor a .dll for a Zinc based Flash application.
After copy&paste a class from the master to the branch, I'm getting some strange compiling errors:
GameInfo.h(15): error C2146: syntax error : missing ';' before identifier 'm_wsVersion'
GameInfo.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
GameInfo.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The addressed code:
// removed the comments
#include "stdafx.h"
#include <string.h>
class GameInfo {
public:
UINT m_uiGameId;
wstring m_wsVersion; // Line 15
UINT m_uiCheckSum;
wstring m_wsFilePath; // Same error report as on line 15
public:
static BOOL createFromFile(wstring path, GameInfo &target); // error "error C2061: syntax error : identifier 'wstring'" thrown
};
I use Visual Studio 2010 and in the IDE itself everything is okay, no syntactical errors or something like that. And as said I did not touch the code, headers seem fine.
Has anyone a clue what about this error?
Try using the string header, and qualifying the namespace:
#include <string>
class GameInfo {
....
std::wstring m_wsVersion;
};
#include <string> is the right standard include in C++ for string classes and use std::wstring.
I strongly recommend AGAINST using a using namespace std; inside one of your headers, as you would force anybody using the header to pull in the std stuff into the global namespace.
I am working on a college project, where I have to implement a simple Scrabble game.
I have a player class (containing a Score and the player's hand, in the form of a std::string, and a score class (containing a name and numeric (int) score).
One of Player's member-functions is Score getScore(), which returns a Score object for that player. However, I get the following error on compile time:
player.h(27) : error C2146: syntax error : missing ';' before identifier 'getScore'
player.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(27) : warning C4183: 'getScore': missing return type; assumed to be a member function returning 'int'
player.h(35) : error C2146: syntax error : missing ';' before identifier '_score'
player.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
player.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Here's lines 27 and 35, respectively:
Score getScore(); //defined as public
(...)
Score _score; //defined as private
I get that the compiler is having trouble recognizing Score as a valid type... But why? I have correctly included Score.h at the beginning of player.h:
#include "Score.h"
#include "Deck.h"
#include <string>
I have a default constructor for Score defined in Score.h:
Score(); //score.h
//score.cpp
Score::Score()
{
_name = "";
_points = 0;
}
Any input would be appreciated!
Thanks for your time,
Francisco
EDIT:
As requested, score.h and player.h:
http://pastebin.com/3JzXP36i
http://pastebin.com/y7sGVZ4A
You've got a circular inclusion problem - relatively easy to fix in this case.
Remove the #include "Player.h" from Score.h.
See this question for an explanation and discussion of what you'd need to do if Score actually used Player.
As for the compiler errors you're getting, that's how Microsoft's compiler reports the use of undefined types -you should learn to mentally translate them all into "Type used in declaration not defined".
Your problem is the recursive include: Score.h is trying to include Player.h, and Player.h is trying to include Score.h. Since the Score class doesn't seem to actually be using the Player class, removing #include "Player.h" from Score.h should solve your problem.
You have a circular dependency problem : Score.h includes Player.h and Player.h includes Score.h.
Do solve this problem, delete your include to Player.h in Score.h and define class Player; if you need to use it in Score class.