I'm trying to create nested QMaps and in one of the QMap containers I have examples of my class as value, but im getting a ton of issues and I don't have any ideas how to fix them
Here's part of header file in which I create a nested QMaps
QMap<int, QMap<int,NormGraph*> > *MyWorkerMap ;
And here is a part of cpp file:
MyWorkerMap = new QMap<int, QMap<int,NormGraph*> >;
I get the following error :
worker.h:1:2: error: unterminated conditional directive // This issue appears when I'm trying to include NormGraph header inside of Worker header
Also I have like 9 issues which are like that:
Expected a type
Expected expression
Use of undeclared identifier(NormGraph, but this issue is quite strange because NormGraph.h was included into Worker.h)
All of these issues appear in one line of code:
QMap<int, QMap<int, NormGraph*> > *MyWorkerMap ;
Related
I'm starting out with Qt Creator and I'm working on mapping some key value pairs (AWG wire gauge sizes as keys and the diameter as value). In using QMap to create the map, I'm getting compile errors of 'awg_map does not name a type'. Can anyone point me in the right direction here?
I've tried adding values two ways that are supposed to work, according to the instructions found at http://doc.qt.io/qt-5/qmap.html. Both ways generate the error noted above.
#include <QMap>
QMap<QString, float> awg_map;
awg_map["20"] = 0.812;
awg_map.insert("21", 0.723);
Looks like G.M. was right with this comment
Statements such as awg_map["20"] = 0.812; and awg_map.insert("21",
0.723); aren't valid at global scope and should be in a function body (for example).
I dropped it all into the MainWindow::MainWindow and it compiled fine. Thanks for that one GM!
First issue: I am trying to import stdlib.h in order to use functions like malloc() and rand(). I am working in threadtest.cc , folder threads. This is the error I get after
#include <stdlib.h>
In file included from ../threads/threadtest.cc:18:0:
/usr/include/stdlib.h:146:33: error: declaration of ‘double atof(const char*) throw ()’ has a different exception specifier
In file included from ../threads/utility.h:57:0,
from ../threads/system.h:12,
from ../threads/threadtest.cc:13:
../machine/sysdep.h:62:8: error: from previous declaration ‘double atof(const char*)’
In file included from ../threads/threadtest.cc:18:0:
/usr/include/stdlib.h:149:33: error: declaration of ‘int atoi(const char*) throw ()’ has a different exception specifier
In file included from ../threads/utility.h:57:0,
from ../threads/system.h:12,
from ../threads/threadtest.cc:13:
../machine/sysdep.h:61:5: error: from previous declaration ‘int atoi(const char*)’
In file included from ../threads/threadtest.cc:18:0:
/usr/include/stdlib.h:771:60: error: declaration of ‘int abs(int) throw ()’ has a different exception specifier
In file included from ../threads/utility.h:57:0,
from ../threads/system.h:12,
from ../threads/threadtest.cc:13:
../machine/sysdep.h:63:5: error: from previous declaration ‘int abs(int)’
../threads/threadtest.cc: In function ‘void shout(int)’:
../threads/threadtest.cc:83:25: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
What can be a reason for this?
Second issue: I am trying to give a forked new thread a name.
Thread * t = new Thread ("my id");
t->Fork(shout, S);
And testing it in function shout:
printf ("%s", currentThread->getName());
This example works fine.
However, if I want to give the thread a "dynamic" id, I use:
sprintf(id, "%d", i);
Thread * t = new Thread (id);
With the same printf for currentThread->getName() it gets me junk:
x�ӿ����_ ���
I have used example from the Nachos documentation as well as tried different ways to transmit a dynamic id using string functions, but nothing worked, only junk.
Thank you for any answers.
I had the same problem in my Nachos homework.
My roommate said maybe it's a incompatibility problem, and suggested that I delete "stdlib.h".
It worked!
I try to compile multiwii code on DUE https://github.com/HefnySco/MultiWii_DUE
I keep getting
C:\Users\MCA9A~1.HEF\AppData\Local\Temp\build4616066844745192383.tmp\EEPROM.cpp.o: In function eeprom_write_block(void*, void*, unsigned int)
C:\Users\MCA9A~1.HEF\AppData\Local\Temp\build4616066844745192383.tmp/Sensors.cpp:307: warning: undefined reference toWire'
I made a separate project to simulate the case and created file called class1.cpp and included Wire_DUE.h and then called it from the main project class Sample1.cpp and it worked using the very same Wire_DUE code.
Kindly advise
At last after 4 days I found the answer.
I used this in def.h
#if defined (__CM3_REV)
#define ARDUINO_DUE
#endif
and when I updated to this
#if defined (ARDUINO_ARCH_SAM)
#define ARDUINO_DUE
#endif
it works .... pls not that in both cases ARDUINO_DUE is defined .... but not sure what is the difference exactly as in both ways ARDUINO_DUE is active.... seems that in some .cpp files it is not active due to other declarations that conflict with __CM3_REV
The manual says I can use:
--warnings_whitelist_file VAL : A file containing warnings to
suppress. Each line should be of the
form
<file-name>:<line-number>? <warning-d
escription>
This is what my whitelist looks like:
ef-utils.js:1 Redeclared variable: ef
ef-utils.js:1 Variable ef first declared in externs-ko.js
ef-validation.js:1 Redeclared variable: ef
ef-validation.js:1 Variable ef first declared in externs-ko.js
And I am still getting warnings while compiling:
ef-utils.js:1: WARNING - Redeclared variable: ef
?var ef = (function (ns, ko) {
^
ef-utils.js:1: WARNING - Variable ef first declared in externs-ko.js
?var ef = (function (ns, ko) {
^
ef-validation.js:1: WARNING - Redeclared variable: ef
?var ef = (function (ns, ko) {
^
ef-validation.js:1: WARNING - Variable ef first declared in externs-ko.js
?var ef = (function (ns, ko) {
^
I just toyed around with the current WhitelistWarningsGuard. I found out that
Line numbers are completely ignored: they are stripped both from the input file and the encountered warnings.
File names are formatted as they are for output, i.e. as they occur on the command line.
There is a colon after the file name, followed by two spaces, followed by the message text without indicator of the severity (WARNING, ERROR).
The main effect of the whitelist appears to be turning errors into warnings. So when applied to warnings, there will be no effect at all.
The WhitelistBuilder mentioned by Tibos is there in the code, but I see no way to use it from the command line.
As it is, that feature appears to be mostly useless for my use cases…
You should use the WhitelistBuilder to build the whitelist file. From the looks of it, you need absolute paths to the files, not relative.
As MvG correctly stated as this flag is implemented it's useless. Though, with pretty light changes to the compiler's code it can be turned to what we all expect from it: suppressing errors and warnings we don't want to see.
See details here: Suppressing or resolving compiler errors in goog.base
I have written the following part of a code that adds two numbers together and outputs the result:
QIntValidator *validator = new QIntValidator(0,50,this);
ui->firstNumber->setValidator(validator);
...
...
In this case, I get the following error:
CS2039: 'setValidator': is not a member of QTextEditor
How can I fix this problem?
Use a text input class that supports validation. You probably want QLineEdit