I'm trying to setup a Google test in Qt and I am having multiple problems, the most annoying of which is "uint was not declared in this scope". This was compiling until recently but now it has decided it cannot find it.
Asked
Active
Viewed 4,116 times
1
-
What's your code? Is the error in your sources or in QTs? If the former, why don't you use `unsigned int` instead of `uint`? – Appleshell May 21 '14 at 14:41
-
The code is a simple for loop using an uint, It was compiling... If I change something every time Qt gives an error my whole project will be destroyed in minutes... – Alan May 21 '14 at 14:44
-
Add following in your code at appropriate place - typedef unsigned int uint – adnan kamili May 21 '14 at 14:46
-
Why are you not using quint64/32/16/8 there? That will manage all the details for you automatically to avoid this kind of situations. Also, for the loop counter, you wish to use size_t, not uint anyway. That is a strange idea. – László Papp May 21 '14 at 14:47
-
Thanks man at least its compiling now....Fixed until I can find some reason behind it. Thank you. – Alan May 21 '14 at 14:49
-
It's not QTs fault that your programs don't follow the C++ standard. `uint` is not a [fundamental data type](http://de.cppreference.com/w/cpp/language/types) and was probably typedef'd to `unsigned int` in some header you included. – Appleshell May 21 '14 at 14:55
-
Its a group project, I cant just changes these things on a whim. It must work if its on the repository. – Alan May 21 '14 at 15:02
-
@user3581328: fix it in the repository? :) – László Papp May 21 '14 at 15:04
-
@Appleshell: QT is the Quick Time project as per tagwiki. ;) – László Papp May 21 '14 at 15:05
1 Answers
1
There are two things to note in here:
1) You could use the Qt types, namely: quint8/16/32/64, depending on range you need.
2) More importantly, you pasted a uint loop counter in comments. For that, you should not even use unsigned int, but size_t.
for (size_t i; i < x.cols; ++i);

László Papp
- 51,870
- 39
- 111
- 135
-
Thanks man, I'll do that in future. Just took a fresh clone from the repository and it compiled... I can feel the frustration squeezing my heart. Anyway, thanks a lot guys :D – Alan May 21 '14 at 14:54
-
@user3581328: I would still use size_t for size type comparison since that is what it is meant for, regardless it is working or not IMHO. :) – László Papp May 21 '14 at 14:55