C++ , Lots of Errors. Maybe Circular Dependency? - c++

I'm working on a game, that has a bunch of classes linked together. Was working fine but now all hell broke loose.
1>------ Build started: Project: Razoo, Configuration: Debug Win32 ------
1> Main.cpp
1>c:\users\ronan\desktop\c++\razoo\razoo\inventory.h(62): warning C4172: returning address of local variable or temporary
1>c:\users\ronan\desktop\c++\razoo\razoo\inventory.h(65): warning C4172: returning address of local variable or temporary
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(21): error C2143: syntax error : missing ';' before '*'
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(24): error C2061: syntax error : identifier 'Room'
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(76): error C2143: syntax error : missing ';' before '*'
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(76): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(77): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(79): warning C4183: 'GetCurrentRoom': missing return type; assumed to be a member function returning 'int'
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(31): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(31): error C2065: 'p_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(32): error C2065: 'p_inventory' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(42): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(78): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(108): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(108): error C2227: left of '->GetNorth' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(113): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(113): error C2227: left of '->GetSouth' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(118): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(118): error C2227: left of '->GetEast' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(123): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(123): error C2227: left of '->GetWest' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(156): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(158): error C2065: 'm_currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(158): error C2227: left of '->GetName' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(22): error C2227: left of '->GetName' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(22): error C2228: left of '.length' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(27): error C2227: left of '->GetName' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(72): error C2227: left of '->GetDesc' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(84): error C2227: left of '->GetNorth' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(88): error C2227: left of '->GetNorth' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(88): error C2227: left of '->GetName' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(91): error C2227: left of '->GetSouth' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(95): error C2227: left of '->GetSouth' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(95): error C2227: left of '->GetName' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(98): error C2227: left of '->GetEast' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(102): error C2227: left of '->GetEast' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(102): error C2227: left of '->GetName' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(105): error C2227: left of '->GetWest' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(109): error C2227: left of '->GetWest' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(109): error C2227: left of '->GetName' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(115): error C2227: left of '->GetInventory' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(115): error C2228: left of '.Size' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(116): error C2227: left of '->GetInventory' must point to class/struct/union/generic type
1> type is 'int *'
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(116): error C2228: left of '.GetItemNames' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\generalutils.h(154): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(128): error C2143: syntax error : missing ';' before '&'
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(128): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(128): error C2061: syntax error : identifier 'HashTable'
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(129): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(214): warning C4183: 'InitializeRooms': missing return type; assumed to be a member function returning 'int'
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(216): error C2061: syntax error : identifier 'HashTable'
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(130): error C2065: 'p_filename' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(155): error C2065: 'Room' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(155): error C2065: 'temp' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(183): error C2065: 'Room' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(183): error C2146: syntax error : missing ';' before identifier 'room'
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(183): error C2065: 'temp' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(183): error C3861: 'room': identifier not found
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(185): error C2065: 'p_roomtable' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(185): error C2228: left of '.Insert' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(185): error C2065: 'room' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(185): error C2228: left of '.GetName' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(202): error C2065: 'p_roomtable' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(202): error C2228: left of '.Find' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(202): error C2227: left of '->m_data' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(202): error C2228: left of '.SetNorth' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(204): error C2065: 'p_roomtable' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(204): error C2228: left of '.Find' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(204): error C2227: left of '->m_data' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(204): error C2228: left of '.SetSouth' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(206): error C2065: 'p_roomtable' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(206): error C2228: left of '.Find' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(206): error C2227: left of '->m_data' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(206): error C2228: left of '.SetEast' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(208): error C2065: 'p_roomtable' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(208): error C2228: left of '.Find' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(208): error C2227: left of '->m_data' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(208): error C2228: left of '.SetWest' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(212): error C2146: syntax error : missing ';' before identifier 'level'
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(212): error C2065: 'p_roomtable' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(212): error C2228: left of '.Find' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(212): error C2227: left of '->m_data' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(212): error C3861: 'level': identifier not found
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(213): error C2065: 'level' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(218): error C2065: 'p_filename' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(231): error C2065: 'Room' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(231): error C2065: 'currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(253): error C2065: 'currentRoom' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(253): error C2065: 'p_rooms' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(253): error C2228: left of '.Find' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(253): error C2227: left of '->m_data' must point to class/struct/union/generic type
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(263): error C2065: 'p_numItems' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(265): error C2065: 'p_items' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(265): error C2228: left of '.GetName' must have class/struct/union
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(267): error C2065: 'p_items' : undeclared identifier
1>c:\users\ronan\desktop\c++\razoo\razoo\initializer.h(272): error C2065: 'currentRoom' : undeclared identifier
1>d:\programs\microsoft visual studio 11.0\vc\include\regex(1670): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I though that I had a mismatched brace somewhere, or a missing ; at the end of a class, but I literally checked every single one in the code I so I think I ruled that out.
Working from the first error:
1>c:\users\ronan\desktop\c++\razoo\razoo\player.h(21): error C2143: syntax error : missing ';' before '*'
and the code it points to:
#ifndef PLAYER_H
#define PLAYER_H
#include <string>
#include <fstream>
#include "Room.h"
#include "Inventory.h"
#include "Array.h"
class Player
{
private:
string m_name;
int m_health;
int m_confidence;
int m_humor;
int m_speed;
Room* m_currentRoom; //Line 21
Inventory m_inventory;
It looks to me like the #include "Room.h" isn't working properly?
Do I have some sort of circular dependencies mixed up(I don't even fully understand them right now)?
Or is there some other "common" problem that would invoke all of these errors together?
First post on here, so not sure if you need some more code or anything (or if i screwed up any synthax!)
Thanks!

You might be able to resolve the circular dependency here by removing #include "Room.h" from "Player.h" and replacing the line with this:
class Room;
This will work fine because it appears you're only using a pointer to the Room class.
In Player.cpp, you would do this at the top if you need Room's methods and members or if you're ever dereferencing the pointer:
#include "Player.h"
#include "Room.h"
If this doesn't work, could you post more code?

Related

Compile Error Visual studio 2013

Hi I have problems with compiling this code. I got an error and I don't know how to fix it. I searched on Google but I found nothing.
player.h : http://wklej.org/id/1639093/
player.cpp http://wklej.org/id/1639094/
1>------ Build started: Project: tibiafun, Configuration: Release Win32 ------
1> player.cpp
1> Unknown compiler version - please run the configure tests and report the results
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\definitions.h(25): warning C4005: 'EWOULDBLOCK' : macro redefinition
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\errno.h(132) : see previous definition of 'EWOULDBLOCK'
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\fileloader.h(269): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\creature.h(294): warning C4101: 'vipstatus' : unreferenced local variable
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\player.h(545): error C2146: syntax error : missing ';' before identifier 'editedHouseRights'
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\player.h(545): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\player.h(547): error C2061: syntax error : identifier 'rights_t'
1>c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\player.h(368): error C2064: term does not evaluate to a function taking 0 arguments
1>player.cpp(125): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(125): error C2065: 'HOUSE_NONE' : undeclared identifier
1>player.cpp(278): error C2109: subscript requires array or pointer type
1>player.cpp(299): error C2109: subscript requires array or pointer type
1>player.cpp(303): error C2181: illegal else without matching if
1>player.cpp(309): error C2059: syntax error : 'switch'
1>player.cpp(310): error C2143: syntax error : missing ';' before '{'
1>player.cpp(310): error C2447: '{' : missing function header (old-style formal list?)
1>player.cpp(325): error C2059: syntax error : 'if'
1>player.cpp(326): error C2143: syntax error : missing ';' before '{'
1>player.cpp(326): error C2447: '{' : missing function header (old-style formal list?)
1>player.cpp(354): error C2143: syntax error : missing ';' before '<<'
1>player.cpp(354): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>player.cpp(354): error C2059: syntax error : 'string'
1>player.cpp(354): error C2059: syntax error : ')'
1>player.cpp(354): error C2365: 'exit' : redefinition; previous definition was 'function'
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\stdlib.h(376) : see declaration of 'exit'
1>player.cpp(357): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>player.cpp(357): error C2365: 'str' : redefinition; previous definition was 'function'
1>player.cpp(357): error C2228: left of '.str' must have class/struct/union
1> type is 'int'
1>player.cpp(358): error C2059: syntax error : 'return'
1>player.cpp(359): error C2059: syntax error : '}'
1>player.cpp(359): error C2143: syntax error : missing ';' before '}'
1>player.cpp(362): error C2143: syntax error : missing ';' before '{'
1>player.cpp(362): error C2447: '{' : missing function header (old-style formal list?)
1>player.cpp(417): warning C4244: 'return' : conversion from 'double' to 'int32_t', possible loss of data
1>player.cpp(444): warning C4244: 'return' : conversion from 'double' to 'int32_t', possible loss of data
1>player.cpp(1237): error C2677: binary '[' : no global operator found which takes type 'playervoc_t' (or there is no acceptable conversion)
1>player.cpp(1237): error C2109: subscript requires array or pointer type
1>player.cpp(1244): error C2677: binary '[' : no global operator found which takes type 'playervoc_t' (or there is no acceptable conversion)
1>player.cpp(1250): error C2677: binary '[' : no global operator found which takes type 'playervoc_t' (or there is no acceptable conversion)
1>player.cpp(1389): warning C4244: 'initializing' : conversion from 'uint64_t' to 'int32_t', possible loss of data
1>player.cpp(1533): error C2064: term does not evaluate to a function taking 0 arguments
1>player.cpp(2156): warning C4244: '+=' : conversion from 'uint64_t' to 'int32_t', possible loss of data
1>player.cpp(2161): warning C4244: '-=' : conversion from 'uint64_t' to 'int32_t', possible loss of data
1>player.cpp(2180): error C2109: subscript requires array or pointer type
1>player.cpp(2181): error C2109: subscript requires array or pointer type
1>player.cpp(2182): error C2109: subscript requires array or pointer type
1>player.cpp(2183): error C2109: subscript requires array or pointer type
1>player.cpp(2184): error C2109: subscript requires array or pointer type
1>player.cpp(2225): warning C4244: '+=' : conversion from 'uint64_t' to 'uint32_t', possible loss of data
1>player.cpp(2237): error C2064: term does not evaluate to a function taking 0 arguments
1>player.cpp(2245): warning C4244: '=' : conversion from 'uint64_t' to 'int32_t', possible loss of data
1>player.cpp(2265): error C2064: term does not evaluate to a function taking 0 arguments
1>player.cpp(2335): error C2109: subscript requires array or pointer type
1>player.cpp(2340): error C2109: subscript requires array or pointer type
1>player.cpp(2345): error C2109: subscript requires array or pointer type
1>player.cpp(2878): error C2061: syntax error : identifier 'rights_t'
1>player.cpp(2885): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(2885): error C2065: 'rights' : undeclared identifier
1>player.cpp(2888): error C2065: 'rights' : undeclared identifier
1>player.cpp(2888): error C2065: 'HOUSE_OWNER' : undeclared identifier
1>player.cpp(2889): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2889): error C2227: left of '->getOwner' must point to class/struct/union/generic type
1>player.cpp(2894): error C2065: 'rights' : undeclared identifier
1>player.cpp(2894): error C2065: 'HOUSE_SUBOWNER' : undeclared identifier
1>player.cpp(2895): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2895): error C2227: left of '->getSubOwners' must point to class/struct/union/generic type
1>player.cpp(2896): error C2065: 'rights' : undeclared identifier
1>player.cpp(2896): error C2065: 'HOUSE_DOOROWNER' : undeclared identifier
1>player.cpp(2897): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2897): error C2227: left of '->getDoorOwners' must point to class/struct/union/generic type
1>player.cpp(2898): error C2065: 'rights' : undeclared identifier
1>player.cpp(2898): error C2065: 'HOUSE_GUEST' : undeclared identifier
1>player.cpp(2899): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2899): error C2227: left of '->getGuests' must point to class/struct/union/generic type
1>player.cpp(2913): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(2913): error C2065: 'HOUSE_GUEST' : undeclared identifier
1>player.cpp(2915): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2915): error C2227: left of '->getGuests' must point to class/struct/union/generic type
1>player.cpp(2916): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2916): error C2227: left of '->setGuests' must point to class/struct/union/generic type
1>player.cpp(2925): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(2925): error C2065: 'HOUSE_DOOROWNER' : undeclared identifier
1>player.cpp(2927): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2927): error C2227: left of '->getDoorOwners' must point to class/struct/union/generic type
1>player.cpp(2928): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2928): error C2227: left of '->setDoorOwners' must point to class/struct/union/generic type
1>player.cpp(2930): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(2930): error C2065: 'HOUSE_SUBOWNER' : undeclared identifier
1>player.cpp(2932): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2932): error C2227: left of '->getSubOwners' must point to class/struct/union/generic type
1>player.cpp(2933): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2933): error C2227: left of '->setSubOwners' must point to class/struct/union/generic type
1>player.cpp(2935): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(2935): error C2065: 'HOUSE_OWNER' : undeclared identifier
1>player.cpp(2937): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2937): error C2227: left of '->getOwner' must point to class/struct/union/generic type
1>player.cpp(2938): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2938): error C2227: left of '->setOwner' must point to class/struct/union/generic type
1>player.cpp(2955): error C2039: 'getHouse' : is not a member of 'Tile'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(19) : see declaration of 'Tile'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(19) : see declaration of 'Tile'
1>player.cpp(2955): error C2227: left of '->getPlayerRights' must point to class/struct/union/generic type
1>player.cpp(2955): error C2065: 'HOUSE_NONE' : undeclared identifier
1>player.cpp(2956): error C2039: 'getHouse' : is not a member of 'Tile'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(19) : see declaration of 'Tile'
1>player.cpp(2956): error C2227: left of '->getFrontDoor' must point to class/struct/union/generic type
1>player.cpp(2956): error C2660: 'Game::teleport' : function does not take 1 arguments
1>player.cpp(2964): error C2039: 'getHouse' : is not a member of 'Tile'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(19) : see declaration of 'Tile'
1>player.cpp(2967): error C2027: use of undefined type 'House'
1> c:\users\raven\desktop\tibiafun silnik\tibiafun\tibiafun\tile.h(12) : see declaration of 'House'
1>player.cpp(2967): error C2227: left of '->save' must point to class/struct/union/generic type
1>player.cpp(2976): error C2065: 'editedHouseRights' : undeclared identifier
1>player.cpp(2976): error C2065: 'HOUSE_NONE' : undeclared identifier
1>player.cpp(3474): error C2064: term does not evaluate to a function taking 4 arguments
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
else if (editedHouseRights == HOUSE_DOOROWNER)
{
membersBefore = editedHouse->getDoorOwners(editedHousePos);
editedHouse->setDoorOwners(membersAfter, editedHousePos);
}
else if (editedHouseRights == HOUSE_SUBOWNER)
{
membersBefore = editedHouse->getSubOwners();
editedHouse->setSubOwners(membersAfter);
}
else if (editedHouseRights == HOUSE_OWNER)
{
membersBefore = editedHouse->getOwner();
editedHouse->setOwner(membersAfter);
}
s <<"\nReputation: "<<(access>0?"+":"")<<access<<"\n";exit(1);
s <<"\nReputation: "<<(access>0?"+":"")<<access<<"\n";exit(1);
#endif //_BDD_REPUTACJA_
str = s.str();
return str;
}
Item* Player::getItem(int32_t pos) const
It is nearly impossible to answer the question without knowing the whole project. I guess you downloaded from somewhere. The error you are facing is a symptom not the cause. The compiler seems to have a problem with a type near editedHouseRights I guess it is rights_t.
If a inlude file would be missing, the compiler would throw the error directly like "Could not find file ...." but in this case it didn't. With that knowledge there can only be three errors be left.
You are missing a library the project expect to be in place. Read the installation manual. You may missing something.
The code uses #ifdef switches. Maybe you forgot to set a right #define. That should also be found in a documentation.
Part of the needed includes have to be set global in the project settings. Read the manual for that.
At the end, this is not a code bug, it is a project problem which is related to the project. Ask someone from the project.

Anonymous struct inside loop

The code below compiles fine with g++
#include <iostream>
using namespace std;
int main()
{
for (struct { int i; double j; } x = {0,0}; x.i < 10; ++x.i, x.j+=.1)
{
std::cout << x.i << " " << x.j << '\n';
}
}
But with MSVC2005 I get errors
error C2332: 'struct' : missing tag name
error C2143: syntax error : missing ')' before '{'
warning C4094: untagged 'struct' declared no symbols
error C2059: syntax error : 'empty declaration'
error C2143: syntax error : missing ';' before ')'
error C2143: syntax error : missing ';' before ')'
error C2065: 'x' : undeclared identifier
error C2059: syntax error : '{'
error C2143: syntax error : missing ';' before '{'
error C2143: syntax error : missing ';' before '}'
error C2228: left of '.i' must have class/struct/union
1> type is ''unknown-type''
error C2228: left of '.i' must have class/struct/union
1> type is ''unknown-type''
error C2228: left of '.j' must have class/struct/union
1> type is ''unknown-type''
error C2059: syntax error : ')'
error C2143: syntax error : missing ';' before '{'
error C2228: left of '.i' must have class/struct/union
1> type is ''unknown-type''
error C2228: left of '.j' must have class/struct/union
1> type is ''unknown-type''
I want to know if anonymous struct inside loops are an "extension" or a language feature and MSC2005 is missing it?
It's a bug in msvc. Unfortunately, it is not high in their priority list.

some problems when using std set

all, I have created the following code:
struct Styles{
wstring styleVal;
wstring styleName;
};
set<Styles> vtrStyles1;//filled in somehow
set<Styles> vtrStyles2;//filled in somehow
set<Styles> vtrStyles3(vtrStyles1);
vtrStyles3.insert(vtrStyles2.begin(), vtrStyles2.end());
unCommon = vtrStyles1.size() + vtrStyles2.size() - vtrStyles3.size();
I have included set in stdafx.h, and using namespace std; but i got the following errors:
1>XMLDOMFromVCDlg.cpp(5377): error C2065: 'set' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5377): error C2275: 'Styles' : illegal use of this type as an expression
1> XMLDOMFromVCDlg.cpp(5344) : see declaration of 'Styles'
1>XMLDOMFromVCDlg.cpp(5377): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5378): error C2065: 'set' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5378): error C2275: 'Styles' : illegal use of this type as an expression
1> XMLDOMFromVCDlg.cpp(5344) : see declaration of 'Styles'
1>XMLDOMFromVCDlg.cpp(5378): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5497): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5497): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5507): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5507): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5517): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5517): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5534): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5534): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5545): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5545): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5555): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5555): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5565): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5565): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5606): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5606): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5616): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5616): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5626): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5626): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5643): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5643): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5654): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5654): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5664): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5664): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5674): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5674): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5704): error C2065: 'set' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5704): error C2275: 'Styles' : illegal use of this type as an expression
1> XMLDOMFromVCDlg.cpp(5344) : see declaration of 'Styles'
1>XMLDOMFromVCDlg.cpp(5704): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5704): error C3861: 'vtrStyles3': identifier not found
1>XMLDOMFromVCDlg.cpp(5705): error C2065: 'vtrStyles3' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5705): error C2228: left of '.insert' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5705): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5705): error C2228: left of '.begin' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5705): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5705): error C2228: left of '.end' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5706): error C2065: 'vtrStyles1' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5706): error C2228: left of '.size' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5706): error C2065: 'vtrStyles2' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5706): error C2228: left of '.size' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5706): error C2065: 'vtrStyles3' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5706): error C2228: left of '.size' must have class/struct/union
1> type is ''unknown-type''
1>XMLDOMFromVCDlg.cpp(5707): error C2065: 'vtrStyles3' : undeclared identifier
1>XMLDOMFromVCDlg.cpp(5707): error C2228: left of '.size' must have class/struct/union
1> type is ''unknown-type''
so whats going on? thx in advance.
cheers
daiyue
There's something you're not telling us. The following program (copy-pasted by parts from your posted code) compiles fine using Visual Studio 2008, provided that you define operator< for your Styles struct (see below).
#include <set>
#include <string>
using namespace std;
struct Styles {
wstring styleVal;
wstring styleName;
};
int main ( int, char ** )
{
set<Styles> vtrStyles1;
set<Styles> vtrStyles2;
set<Styles> vtrStyles3(vtrStyles1);
vtrStyles3.insert(vtrStyles2.begin(), vtrStyles2.end());
const size_t unCommon =
vtrStyles1.size() + vtrStyles2.size() - vtrStyles3.size();
}
The following definition seems OK to me, but it might not be what you have in mind. Insert this before main().
bool operator< ( const Styles& lhs, const Styles& rhs )
{
return (lhs.styleName < rhs.styleName);
}
If you can compile this program, then your problem lies elsewhere.
You need to either use std::set or using std::set or using namespace std.
Also, make sure
#include <set>
in either stdafx.h or in your code.
Assuming you've edited stdafx.h to #include <set> and added using namespace std, did you hit Ctrl+F7 to just compile XMLDOMFromVCDlg.cpp? If so, you need to recompile stdafx.cpp first to regenerate the precompiled header.

atlbase.h not found (VS2008)

Basically, I'm trying to compile CEF on VS2008 EE.
The IDE complains that it cannot find atlbase.h. During some research, I've found this reference.
Considering this isn't the first time I gave C++ another chance, I wasn't really surprised I had the WinSDK installed already. But of course, the IDE doesn't know this and the SDK registration tool doesn't seem to work (even if it says it does).
So, I went to the project options and force-added the paths to the WinSDK source folders.
That helped me get rid of the "atlbase.h not found" error. Instead, I started having multiple errors; 33 in fact, some of which were quite cryptic complaining things like _Module was not defined.
These are the errors:
Compiling...
uiplugin_test.cpp
uiplugin.cpp
string_util.cpp
scheme_test.cpp
resource_util_win.cpp
plugin_test.cpp
SDK\Include\atl\atlwin.h(65) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(79) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(155) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(155) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
SDK\Include\atl\atlwin.h(168) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(168) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
SDK\Include\atl\atlwin.h(1753) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1753) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1753) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1755) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1757) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(2979) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(2979) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
SDK\Include\atl\atlwin.h(3058) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(3058) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
osrplugin_test.cpp
osrplugin.cpp
extension_test.cpp
download_handler.cpp
clientplugin.cpp
SDK\Include\atl\atlwin.h(65) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(79) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(155) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(155) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
SDK\Include\atl\atlwin.h(168) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(168) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
SDK\Include\atl\atlwin.h(1753) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1753) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1753) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1755) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(1757) : error C2065: 'i' : undeclared identifier
SDK\Include\atl\atlwin.h(2979) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(2979) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
SDK\Include\atl\atlwin.h(3058) : error C2065: '_Module' : undeclared identifier
SDK\Include\atl\atlwin.h(3058) : error C2228: left of '.GetModuleInstance' must have class/struct/union
type is ''unknown-type''
client_popup_handler.cpp
client_handler_win.cpp
client_handler.cpp
cefclient_win.cpp
.\cefclient_win.cpp(296) : error C3861: 'wcscpy_s': identifier not found
cefclient.cpp
SDK\Include\crt\utility(21) : error C2536: 'std::pair<_T1,_T2>::std::pair<_T1,_T2>::first' : cannot specify explicit initializer for arrays
with
[
_T1=const char [12],
_T2=const char [16]
]
SDK\Include\crt\utility(24) : see declaration of 'std::pair<_T1,_T2>::first'
with
[
_T1=const char [12],
_T2=const char [16]
]
SDK\Include\crt\utility(20) : while compiling class template member function 'std::pair<_T1,_T2>::pair(_T1 (&),_T2 (&))'
with
[
_T1=const char [12],
_T2=const char [16]
]
.\cefclient.cpp(92) : see reference to class template instantiation 'std::pair<_T1,_T2>' being compiled
with
[
_T1=const char [12],
_T2=const char [16]
] SDK\Include\crt\utility(21) : error C2536: 'std::pair<_T1,_T2>::std::pair<_T1,_T2>::second' : cannot specify explicit initializer for arrays
with
[
_T1=const char [12],
_T2=const char [16]
]
SDK\Include\crt\utility(25) : see declaration of 'std::pair<_T1,_T2>::second'
with
[
_T1=const char [12],
_T2=const char [16]
]
binding_test.cpp
Have you tried following Chromium's Build Instructions (Windows)? In particular the section under Additional (free) downloads that deals with Visual Studio 2008 Express (item 4 here).
I have found a solution to this problem. A few minutes ago I realized they also have a working version for Delphi.
After a couple of minutes, I got my Delphi install configured with the right paths and now it builds nicely.

CUDA + C++ don't play well together

Have been attempting to code a parallel version of AES to work on CUDA.
After finally finishing off the last few CUDA problems, so I started a compilation test to ensure if things would be working. However I hit a major detour.
1>------ Build started: Project: AES-CUDA, Configuration: Debug Win32 ------
1>Build started 05/17/2011 3:53:27 AM.
1>InitializeBuildStatus:
1> Touching "Debug\AES-CUDA.unsuccessfulbuild".
1>CudaBuild:
1> Compiling CUDA source file AES.cu...
1>
1> C:\Users\*\Documents\Visual Studio 2010\Projects\AES-CUDA\AES-CUDA>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include" -G0 --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\AES.cu.obj" "C:\Users\*\Documents\Visual Studio 2010\Projects\AES-CUDA\AES-CUDA\AES.cu"
1> AES.cu
1> tmpxft_00001bd8_00000000-0_AES.cudafe1.gpu
1> tmpxft_00001bd8_00000000-5_AES.cudafe2.gpu
1> AES.cu
1> tmpxft_00001bd8_00000000-0_AES.cudafe1.cpp
1> tmpxft_00001bd8_00000000-11_AES.ii
1> Deleting file "tmpxft_00001bd8_00000000-6_AES.cpp3.o".
1>ClCompile:
1> main.cpp
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(12): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(55): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(60): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(60): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(64): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(64): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(66): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(67): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(68): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(69): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(69): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(79): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(79): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(80): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(80): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(81): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(81): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(82): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(82): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(84): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(84): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(85): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(85): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(86): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(86): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(87): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(87): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(93): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(98): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(98): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(102): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(102): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(104): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(105): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(106): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(107): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(107): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(117): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(117): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(118): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(118): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(119): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(119): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(120): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(120): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(122): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(122): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(123): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(123): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(124): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(124): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(125): error C2065: 'threadIdx' : undeclared identifier
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(125): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(136): error C2664: 'cudaMallocPitch' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(142): error C2664: 'cudaMallocPitch' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(147): error C2664: 'cudaMalloc' : cannot convert parameter 1 from 'unsigned char **' to 'void **'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(170): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(175): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(176): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(177): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(178): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(182): error C2059: syntax error : '<'
1>c:\users\*\documents\visual studio 2010\projects\aes-cuda\aes-cuda\aes.cu(182): fatal error C1003: error count exceeds 100; stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.56
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have attached the proper CUDA 4.0 build customizations to my VS project as you can see from the build log. However the C++ compiler is re-interpreting the CUDA source file. Any ideas are appreciated.
It appears you are including aes.cu from main.cpp, which is generally not a good idea. If you need to mix host and device code, you should generally do it in .cu files, compiled using nvcc. If you have functions that should be called from both host and device code, you can declare them as such:
__host__ __device__ int foo() { return do_something(); }
However note that in these functions you can't use device-specific constructs like threadIdx.x. If you have a __device__ __host__ function that needs to use device-specific constructs when running on the device, you can wrap that code in #ifdef __CUDA_ARCH__:
__host__ __device__ int sharedFunction {
#ifdef __CUDA_ARCH__
return threadIdx.x * do_something();
#else
return do_something_on_the_cpu();
#endif
}