[Interest] Understanding Qt Macros
Reinhardt Behm
rbehm at hushmail.com
Sun Jan 4 06:24:08 CET 2015
On 03.01.2015 21:40, Alejandro Exojo wrote:
> El Saturday 03 January 2015, Reinhardt Behm escribió:
>> I have used them to put together a commonly used header (see attached
>> project.h), that I also use as a precompiled header.
>> This way all the required <Qt...> headers are automatically included.
> Why do such thing? Adding a `using namespace std` in a common header seems
> like a terrible idea to begin with. You should import namespaces only when you
> need them, and as much scoped as you can. Or just using what you want (`using
> std::cout` if you only use that). Seems a recipe for future name clashes that
> will give strange compilation errors if you use reasonably name variables.
>
> Including all the Qt headers is something that I don't understand either. Even
> with precompiled headers.
>
A precompiled header is of not much use if it does not include the most
biggest and most used headers. And the Qt-headers are big.
I did not have many name clashes even with "reasonably named variables"
or perhaps because of that, using many different programming languages
in the past 30+ years and Qt since 2.x. Most of those do not have the
concept of namespaces.
The Qt people have done a good job of not polluting the global namespace.
If other libraries have such a problems, I have found that often they
have other even worse deficiencies. So I will avoid them. There is no
room in critical software like avionics for which I often work for such
stuff.
The "using namespace std" is more of historic relict. When using Qt I
really do not use much of the std namespace anymore. Time to remove it
in 2014.
--
Reinhardt, wishing everyone a successful and happy new year.
More information about the Interest
mailing list