Hi,
ich verusche gerade einige Klassen in namespaces zu legen und bekomme dadurch Compilererrors (VS2017 Commuinity)
Error C2039 'logging': is not a member of 'spe' (compiling source file c_logging.cpp)
Error C3083 'logging': the symbol to the left of a '::' must be a type (compiling source file c_logging.cpp)
Error C2039 'C_Logging': is not a member of 'spe' (compiling source file c_logging.cpp)
Error C2143 syntax error: missing ';' before '*' (compiling source file c_logging.cpp)
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file c_logging.cpp)
Error C2238 unexpected token(s) preceding ';' (compiling source file c_logging.cpp)
Error C2039 'timeing': is not a member of 'spe' (compiling source file c_logging.cpp)
Error C3083 'timeing': the symbol to the left of a '::' must be a type (compiling source file c_logging.cpp)
Error C2039 'C_Timer': is not a member of 'spe' (compiling source file c_logging.cpp)
Error C2143 syntax error: missing ';' before '*' (compiling source file c_logging.cpp)
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file c_logging.cpp)
Error C2238 unexpected token(s) preceding ';' (compiling source file c_logging.cpp)
Error C2039 'logging': is not a member of 'spe' (compiling source file main.cpp)
Error C3083 'logging': the symbol to the left of a '::' must be a type (compiling source file main.cpp)
Error C2039 'C_Logging': is not a member of 'spe' (compiling source file main.cpp)
Error C2143 syntax error: missing ';' before '*' (compiling source file main.cpp)
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file main.cpp)
Error C2238 unexpected token(s) preceding ';' (compiling source file main.cpp)
Error C2039 'timeing': is not a member of 'spe' (compiling source file main.cpp)
Error C3083 'timeing': the symbol to the left of a '::' must be a type (compiling source file main.cpp)
Error C2039 'C_Timer': is not a member of 'spe' (compiling source file main.cpp)
Error C2143 syntax error: missing ';' before '*' (compiling source file main.cpp)
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file main.cpp)
Error C2238 unexpected token(s) preceding ';' (compiling source file main.cpp)
und hier noch der Code
engine_core.h
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#pragma once
#include "main.hpp"
namespace spe
{
namespace core
{
class engine_core
{
public:
engine_core();
~engine_core();
private:
spe::logging::C_Logging *log;// = nullptr;
spe::timeing::C_Timer *running_timer;// = nullptr;
};
engine_core::engine_core()
{
//std::shared_ptr<C_Logging> log(new C_Logging()); // start logging
//std::shared_ptr<C_Timer> running_timer(new C_Timer()); // start timer
//running_timer->start();
}
engine_core::~engine_core()
{
}
}
}
|
c_timer.h
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include "main.hpp"
namespace spe
{
namespace timeing
{
class C_Timer
{
public:
C_Timer() {};
virtual ~C_Timer() {};
void start() // start timer
{
starttime = std::chrono::high_resolution_clock::now();
};
int stop() // stoptimer and return of millisec since last start
{
stoptime = std::chrono::high_resolution_clock::now();
std::chrono::high_resolution_clock::duration diff = stoptime - starttime;
return std::chrono::duration_cast<std::chrono::milliseconds>(diff).count();
};
int restart() // restart timer ans returns millisec since last call
{
stoptime = std::chrono::high_resolution_clock::now();
std::chrono::high_resolution_clock::duration diff = stoptime - starttime;
starttime = stoptime;
//starttime = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(diff).count();
}
private:
std::chrono::high_resolution_clock::time_point starttime;
std::chrono::high_resolution_clock::time_point stoptime;
};
}
}
|
c_logging.hpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#pragma once
#include "main.hpp"
//class spe::C_Logging;
namespace spe
{
namespace logging
{
class C_Logging
{
public:
C_Logging();
~C_Logging();
void operator<< (std::string data) const;
void operator<< (char *) const;
private:
std::ofstream *file;
std::string filename = "engine.log";
};
}
}
|
c_logging.cpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "c_logging.hpp"
namespace spe
{
namespace logging {
C_Logging::C_Logging()
: filename(filename)
{
file = new std::ofstream();
//file->open(filename);
if (file->is_open())
std::cerr.rdbuf(file->rdbuf());
}
C_Logging::~C_Logging()
{
if (file->is_open())
file->close();
file = nullptr;
}
void C_Logging::operator<<(std::string text) const
{
std::cerr << __DATE__ << " " << __TIME__ << " " << text << std::endl;
}
void C_Logging::operator<<(char *text) const
{
std::cerr << __DATE__ << " " << __TIME__ << " " << text << std::endl;
}
}
}
|
main.hpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#pragma once
/*
File: main.hpp
Desc: main inlude file
*/
#include <iostream>
#include <fstream>
#include <string>
#include <memory>
#include <chrono>
#include "engine_core.h"
#include "c_logging.hpp"
#include "c_timer.hpp"
|
main.cpp
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
/*
File: main.cpp
Desc: mainfile
*/
#include "main.hpp"
int main(int argv, char *argc)
{
std::unique_ptr<spe::core::engine_core> engine(new spe::core::engine_core());
char a;
std::cin >> a;
}
|
Bitte um hilfe
mfg
sIR_pAPILEIN