I'm trying to declare an object in c++:
Polygon poly;
and the compiler is telling that that "Polygon is ambigious". What does that mean?
Here is the full code:
#include "Graph.h"
#include "Simple_window.h"
#include "point.h"
#include "Window.h"
using namespace Graph_lib;
int main(int argc, char **argv)
{
Point tl(100,100);
Simple_window win(tl,600,400,"canvas");
Axis xa(Axis::x, Point(20,300),280 ,10, "x axis");
win.attach(xa);
win.set_label("canvas #2");
win.wait_for_button();
Axis ya(Axis::y, Point(20,300),280 ,10, "y axis");
ya.set_color(Color::cyan);
ya.label.set_color(Color::dark_red);
win.attach(ya);
win.set_label("canvas #3");
win.wait_for_button();
Function sine(sin,0,100, Point(20,150),1000,50,50);
win.attach(sine);
win.set_label("canvas #4");
win.wait_for_button();
sine.set_color(Color::blue);
Polygon poly; ///ERROR! Ambigious!!!
poly.add(Point(300,200));
poly.add(Point(350,100));
poly.add(Point(400,200));
poly.set_color(Color::red);
poly.set_style(Line_style::dash);
win.attach(poly);
win.set_label("canvas #5");
win.wait_for_button();
}
As you can see there's a conflict between the user written header, and some header included some where. This is after have recently installed FLTK 1.3.
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1> Graph.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(65): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(131): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(132): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(389): warning C4800: 'void *' : forcing value to bool 'true' or 'false' (performance warning)
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.cpp(414): warning C4018: '>=' : signed/unsigned mismatch
1> GUI.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130): warning C4018: '<' : signed/unsigned mismatch
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130) : while compiling class template member function 'Graph_lib::Vector_ref<T>::~Vector_ref(void)'
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(99) : see reference to class template instantiation 'Graph_lib::Vector_ref<T>' being compiled
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> Simple_window.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130): warning C4018: '<' : signed/unsigned mismatch
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130) : while compiling class template member function 'Graph_lib::Vector_ref<T>::~Vector_ref(void)'
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(99) : see reference to class template instantiation 'Graph_lib::Vector_ref<T>' being compiled
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> test.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2872: 'Polygon' : ambiguous symbol
1> could be 'c:\program files (x86)\microsoft sdks\windows\v7.0a\include\wingdi.h(4548) : BOOL Polygon(HDC,const POINT *,int)'
1> or 'c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(256) : Graph_lib::Polygon'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2872: 'Polygon' : ambiguous symbol
1> could be 'c:\program files (x86)\microsoft sdks\windows\v7.0a\include\wingdi.h(4548) : BOOL Polygon(HDC,const POINT *,int)'
1> or 'c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(256) : Graph_lib::Polygon'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2146: syntax error : missing ';' before identifier 'poly'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): warning C4551: function call missing argument list
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(36): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(37): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(37): error C2228: left of '.add' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(38): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(38): error C2228: left of '.add' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(39): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(39): error C2228: left of '.add' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(41): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(41): error C2228: left of '.set_color' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(42): error C2065: 'poly' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(42): error C2228: left of '.set_style' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\test.cpp(43): error C2065: 'poly' : undeclared identifier
1> Window.cpp
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(45): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4305: 'initializing' : truncation from 'Graph_lib::Color::Transparency' to 'char'
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(47): warning C4309: 'initializing' : truncation of constant value
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(107): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(112): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(117): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\window.cpp(74): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\window.cpp(76): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130): warning C4018: '<' : signed/unsigned mismatch
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\graph.h(130) : while compiling class template member function 'Graph_lib::Vector_ref<T>::~Vector_ref(void)'
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> c:\users\bryan\documents\visual studio 2010\projects\test\test\gui.h(99) : see reference to class template instantiation 'Graph_lib::Vector_ref<T>' being compiled
1> with
1> [
1> T=Graph_lib::Button
1> ]
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It means that you've declared two or more entities (types, functions, variables, etc.) called Polygon, and the compiler can't tell which you mean in this context.
The complete error message should tell you which declarations are causing the ambiguity. Without seeing them, it's hard to guess how best to fix the error.
UPDATE: Now you've posted some code, but not the complete error message or the problematic declarations, I'll hazard a guess that Polygon is declared in both the global and Graph_lib namespaces. You then dump the whole of Graph_lib into the global namespace, making the name ambiguous. If this is the case, then you'll need to specify ::Polygon or Grapg_lib::Polygon to resolve the ambiguity.
because there also have a Polygon defined in wingdi.h
THE SOLUTION IS Put NOGDI in preprocessor. In Visual Studio Project Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> add NOGDI.
Related
Code response at Code Blocks(MinGW)How can I get the information about the Physical Memory, Virtual Memory & CPU register usage of my ".c" code running in Microsoft Visual C++ 2010 Express ?Code response with VC++ 2010 Express
First let me clarify my issues in depth.
I'm new to Visual Studio. Every time I used "Code Blocks" with GNU GCC compiler (mingW).
For the timing if I just focus on Physical & Virtual memory usage. Here is the small code just for testing purpose which I used with mingW. It worked properly.
#include <windows.h>
#include<stdio.h>
#include<stdlib.h>
#define DIV 1024
#define WI 7
#include <Psapi.h>
void main()
{
int a;float b;char c;
const unsigned char tmpe[320];
static const float weights[422];
printf("sz of a is %d \n",sizeof(a));
printf("sz of b is %d \n",sizeof(b));
printf("size of frames is %d \n", sizeof(tmpe));
printf("sz of c is %d \n",sizeof(c));
printf("size of yooo is %d \n", sizeof(weights));
PROCESS_MEMORY_COUNTERS_EX vm_cp;
GetProcessMemoryInfo(GetCurrentProcess(),
(PROCESS_MEMORY_COUNTERS*)&vm_cp,sizeof(vm_cp));
SIZE_T virtualMemoryusedbyMyCp = vm_cp.PrivateUsage; /* Virtual memory
currently used by current process, vm_cp = virtual memory of current process */
printf ("There are %*I64d Kbytes of virtual memory used by my Current
Process.\n",
WI, virtualMemoryusedbyMyCp/DIV);
SIZE_T physMemoryUsedbyMyCP = vm_cp.WorkingSetSize; /*Physical Memory used by
Current Process */
printf ("There are %*I64d Kbytes of Physical memory used by my Current
Process.\n",WI, physMemoryUsedbyMyCP/DIV);
}
But when I used the same code with Visual studio 2010 express
I'm getting this long list of errors which I'm unable to understand.
Here is the compilation error with VS 2010 express
1>------ Build started: Project: Yooo_size code, Configuration: Debug Win32
------
1> size demo.c
1>size demo.c(50): error C2275: 'PROCESS_MEMORY_COUNTERS_EX' : illegal use of
this type as an expression
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Psapi.h(394) : see
declaration of 'PROCESS_MEMORY_COUNTERS_EX'
1>size demo.c(50): error C2146: syntax error : missing ';' before identifier
'vm_cp'
1>size demo.c(50): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(51): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(51): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(52): error C2275: 'SIZE_T' : illegal use of this type as an
expression
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\basetsd.h(421) : see
declaration of 'SIZE_T'
1>size demo.c(52): error C2146: syntax error : missing ';' before identifier
'virtualMemoryusedbyMyCp'
1>size demo.c(52): error C2065: 'virtualMemoryusedbyMyCp' : undeclared
identifier
1>size demo.c(52): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(52): error C2224: left of '.PrivateUsage' must have struct/union
type
1>size demo.c(54): error C2065: 'virtualMemoryusedbyMyCp' : undeclared
identifier
1>size demo.c(55): error C2275: 'SIZE_T' : illegal use of this type as an
expression
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\basetsd.h(421) : see
declaration of 'SIZE_T'
1>size demo.c(55): error C2146: syntax error : missing ';' before identifier
'physMemoryUsedbyMyCP'
1>size demo.c(55): error C2065: 'physMemoryUsedbyMyCP' : undeclared identifier
1>size demo.c(55): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(55): error C2224: left of '.WorkingSetSize' must have
struct/union type
1>size demo.c(57): error C2065: 'physMemoryUsedbyMyCP' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
In the past (Qt 4.8), I've used the modeltest class to test QAbstractItemModel implementations. However, it seems with Qt 5 they've broken compatibility as a slew of errors erupts when trying to compile it out of the box, including calls to functions like reset() which are no longer members of QAbstractItemModel.
Does anyone know of an updated repository, or has anyone fixed modeltest of their own accord? I'm specifically using Qt 5.3.1.
ERRORS:
C:\Documents\Visual Studio 2013\Projects\modeltest\dynamictreemodel.cpp(306): error C2039: 'reset' : is not a member of 'DynamicTreeModel'
1> c:\documents\visual studio 2013\projects\modeltest\dynamictreemodel.h(51) : see declaration of 'DynamicTreeModel'
1> modeltest.cpp
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(419): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(419): error C2275: 'QString' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtCore/qstring.h(213) : see declaration of 'QString'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(423): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(423): error C2275: 'QString' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtCore/qstring.h(213) : see declaration of 'QString'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(427): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(427): error C2275: 'QString' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtCore/qstring.h(213) : see declaration of 'QString'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(433): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(433): error C2275: 'QSize' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtCore/qsize.h(51) : see declaration of 'QSize'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(439): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(439): error C2275: 'QFont' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtGui/qfont.h(58) : see declaration of 'QFont'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(452): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(452): error C2275: 'QColor' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtGui/qcolor.h(65) : see declaration of 'QColor'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(457): error C2065: 'qVariantCanConvert' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\modeltest.cpp(457): error C2275: 'QColor' : illegal use of this type as an expression
1> C:\Qt\qt-5.3.1-x64-msvc2010-opengl\qt-5.3.1-x64-msvc2010-opengl\include\QtGui/qcolor.h(65) : see declaration of 'QColor'
1> tst_modeltest.cpp
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(114): error C2065: 'QTreeWidget' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(114): error C2146: syntax error : missing ';' before identifier 'widget'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(114): error C2065: 'widget' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(116): error C2065: 'widget' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(116): error C2228: left of '.model' must have class/struct/union
1> type is 'unknown-type'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(116): error C2512: 'ModelTest' : no appropriate default constructor available
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(118): error C2065: 'QTreeWidgetItem' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(118): error C2065: 'root' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(118): error C2061: syntax error : identifier 'QTreeWidgetItem'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(120): error C2061: syntax error : identifier 'QTreeWidgetItem'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(122): error C2065: 'QTreeWidgetItem' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(122): error C2065: 'root' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(122): error C2227: left of '->child' must point to class/struct/union/generic type
1> type is 'unknown-type'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(123): error C2065: 'root' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(123): error C2227: left of '->removeChild' must point to class/struct/union/generic type
1> type is 'unknown-type'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(124): error C2065: 'QTreeWidgetItem' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(124): error C3867: 'QObject::parent': function call missing argument list; use '&QObject::parent' to create a pointer to member
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(124): error C2061: syntax error : identifier 'QTreeWidgetItem'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(126): error C2065: 'widget' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(126): error C2228: left of '.setItemHidden' must have class/struct/union
1> type is 'unknown-type'
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(126): error C3867: 'QObject::parent': function call missing argument list; use '&QObject::parent' to create a pointer to member
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(128): error C2065: 'widget' : undeclared identifier
1>C:\Documents\Visual Studio 2013\Projects\modeltest\tst_modeltest.cpp(128): error C2228: left of '.sortByColumn' must have class/struct/union
It seems like this can be fixed with a few easy steps:
The reset() error is testing a deprecated function, and can be commented out.
The qVariantCanConvert errors can be fixed by following the advice here on transitioning from Qt 4.8 to Qt 5
The rest of the errors can be solved by making sure all the appropriate headers are included.
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.
I'll be very pleased if you help.
My IDE is VS2010.
I'm using boost 1.47.0, especially boost::asio.
After some days of developing I decided to add log4cxx.
log4cxx needs to change calling convention to __stdcall
I surprisingly got lots of compiling error. They are ~ 70 errors.
I've googled a bit and found these:
#define BOOST_BIND_ENABLE_STDCALL
#define BOOST_MEM_FN_ENABLE_STDCALL
It helps. Now there are just ~10 errors.
Here there are:
1>ClCompile:
1> main.cpp
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(61): error C2373: '_InterlockedCompareExchange' : redefinition; different type modifiers
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(214) : see declaration of '_InterlockedCompareExchange'
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(62): error C2373: '_InterlockedExchange' : redefinition; different type modifiers
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(192) : see declaration of '_InterlockedExchange'
1>D:\Development\lib\boost_1_47_0\boost/detail/interlocked.hpp(63): error C2373: '_InterlockedExchangeAdd' : redefinition; different type modifiers
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\intrin.h(204) : see declaration of '_InterlockedExchangeAdd'
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C2446: '==' : no conversion from 'long' to 'long (__stdcall *)(volatile long *,long,long)'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C2040: '==' : 'long (__stdcall *)(volatile long *,long,long)' differs in levels of indirection from 'long'
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/sp_counted_base_w32.hpp(92): error C3861: '_InterlockedCompareExchange': identifier not found
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C3861: '_InterlockedExchange': identifier not found
1>D:\Development\lib\boost_1_47_0\boost/smart_ptr/detail/spinlock_w32.hpp(62): error C2440: 'initializing' : cannot convert from 'long (__stdcall *)(volatile long *,long)' to 'long'
1> There is no context in which this conversion is possible
1>D:\Development\lib\boost_1_47_0\boost/asio/detail/impl/signal_set_service.ipp(74): error C2664: 'signal' : cannot convert parameter 2 from 'void (__stdcall *)(int)' to 'void (__cdecl *)(int)'
1> None of the functions with this name in scope match the target type
1>D:\Development\lib\boost_1_47_0\boost/asio/detail/impl/signal_set_service.ipp(246): error C2664: 'signal' : cannot convert parameter 2 from 'void (__stdcall *)(int)' to 'void (__cdecl *)(int)'
1> None of the functions with this name in scope match the target type
1>main.cpp(20): warning C4007: 'main' : must be '__cdecl'
How can I solve them?
Any little ideas or hints?
You also need
#define BOOST_USE_WINDOWS_H
and possibly /Gz (__stdcall)
If your code looks something like:
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"
using namespace log4cxx;
using namespace log4cxx::helpers;
int main()
{
//stuff
}
and you compile with -llog4cxx then you should be fine.
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
}