[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MOC intermediate files don't have "config.h" inclusion
From: |
Daniel J Sebald |
Subject: |
MOC intermediate files don't have "config.h" inclusion |
Date: |
Tue, 19 Mar 2013 14:52:21 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16 |
It appears that the Qt intermediate files created by MOC go deep into
the standard headers and then come back out to libgnu/unistd.h. That
file requires the definition
_GL_INLINE_HEADER_BEGIN
which is in the main "config.h".
The Qt MOC files are a short hunk of code with tables and hooks to make
all the signals/slots within the associated C++ file work in the Qt system.
The problem is that the MOC files, being generated, cannot include the
file "config.h" the way that, say, dialog.cc can. My temporary solution
is to include the "config.h" file in dialog.h. I believe the other GUI
code might be indirectly doing the same thing because in
"symbol-information.h" is this comment:
// FIXME -- we should not be including config.h in header files.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
I'm going to leave a similar FIXME in my working code, but just
momentarily. I wonder if we can come up with some other means of doing
this via the compilation process.
It is kind of difficult to differentiate "moc-dialog.cc" from
"dialog.cc" in a Makefile so we can't selectively include "config.h" at
the command line for MOC.cc files. (One wouldn't be able to name any
file prefixed by "moc".)
libgnu/unistd.h is something we can't change, right? I.e., we can't add
"config.h" to the to of unistd.h.
Maybe there is a way to include stuff via moc-qt4, but I doubt it. I
tried getting creative with the use of the "-f" option and try to
squeeze #include "config.h" in ahead of the name of the header file:
define CONFIGHFIRST
$(top_builddir)/config.h"
hi"
endef
moc-%.cc: %.h
$(MOC) -f'$(CONFIGHFIRST)' -o$@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
$(AM_CPPFLAGS) $(CPPFLAGS) $(MOC_CPPFLAGS) $(liboctgui_la_CPPFLAGS) $<
but it isn't working out so well. The newline character causes moc-qt4
to process prematurely. The -f will change the name of the header file
inside the generated code, but I think only one inclusion is allowed.
If it is the case that almost every .cc file in the source tree requires
"config.h", couldn't we just force that inclusion at the compilation
command line for all .cc files? Here is what the MOC generates:
/****************************************************************************
** Meta object code from reading C++ file 'dialog.h'
**
** Created: Tue Mar 19 14:49:34 2013
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.4)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../../octave/libgui/guifcn/dialog.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'dialog.h' doesn't include <QObject>."
I think that if we forced an inclusion of "config.h" at the gcc command
line the above error message should still pass.
Dan
- MOC intermediate files don't have "config.h" inclusion,
Daniel J Sebald <=