6 ms·
I never understood the problem with moc. It's an extra step during the build process, yes. But it's quick and very easy to integrate in modern build tools (for
by simfoo 10y ago
I never understood the problem with moc. It's an extra step during the build process, yes. But it's quick and very easy to integrate in modern build tools (for example CMake).
- beagle3 10y agoIt's been 14 years since I last used a precompiler like moc (it wasn't moc), and it was a pain - all the nice IDE features (syntax highlighting, code completion, automatic indentation, source level debugging, etc.) were all broken in subtle or major ways. moc (specifically) has a long track record that I would expect this to be solved -- no experience myself -- but regardless of how easy it is to add another build step, most precompilation stages are correlated with reduced tool functionality.
- simfoo 10y agomoc isn't a precompiler - it will not change your code in any way! It merely generates additional code based on your classes containing meta information
- pjmlp 10y agoMe neither, specially because most C and C++ developers seem to be quite happy to use compiler specific extensions to ANSI C and ANSI C++. So using moc isn't ok as it ties the application to an extra tool, but using features that tie the application to a specific compiler is ok.
- octorian 10y agoFrom what I can understand, all the arguments seem to derive from some grumpy old curmudgeon who took a passing glance at Qt 15 years ago, without actually understanding what it is or does, and said "Why do I need this thing? I don't like extra stuff because 'reasons'. Its better if I reinvent the wheel myself. Preprocessors are always bad. Now get off my lawn!" Moc was introduced at a time that C++ really did not have the built-in features necessary to create a framework like Qt. Since then, a few things have happened. First, C++ itself has (very) slowly gained some of those features. Second, the Qt developers have found additional things they can do by having the "moc" tool integrated into their build processes, and thus have expanded its scope. But even if a day comes that Qt can totally get rid of "moc" in theory, in actuality there will still be a lot of people who actually need to use C++ compilers that still haven't implemented whatever new version of the standard accomplishes this.