Interrogate not working after migration to 1.10.0

Interrogate was working well. However, after migrating to Panda3D 1.10.0 (from git) it’s started throwing very strange errors:

Interrogating base
*** Error in config_dna.h near line 27, column 46:
NotifyCategoryGetCategory_dna has conflicting declaration as class NotifyCategor
yGetCategory_dna {
public:
  NotifyCategoryGetCategory_dna(void);
  static NotifyCategory *get_category(void);
}
Error parsing file: 'dnabase.h'

This is dnabase.h

#pragma once

#ifdef NDEBUG
#undef NDEBUG
#endif

#include <pandabase.h>
#include <notifyCategoryProxy.h>

#pragma warning (disable : 4273)
#pragma warning (disable : 4275)

#if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC)
    #ifdef BUILDING_DNA
        #define EXPCL_DNA __declspec(dllexport)
        #define EXPTP_DNA
    #else
        #define EXPCL_DNA __declspec(dllimport)
        #define EXPTP_DNA extern
    #endif

#else
    #define EXPCL_DNA
    #define EXPTP_DNA
#endif

NotifyCategoryDecl(dna, EXPCL_DNA, EXPTP_DNA);
extern void init_libpandadna();

The command:

The following command return a non-zero value (1): C:\panda3d-1.10.0\bin\interrogate -D__inline -DCPPPARSER -DP3_INTERROGATE=1 -D__cplusplus -fnames -string -refcount -assert -S C:\panda3d-1.10.0\include\parser-inc -S C:\panda3d-1.10.0\include -I C:\panda3d-1.10.0\include -Isrc/base -Isrc/suit -Isrc/components -srcdir src/base -oc built10/base_igate.cxx -od built10/base.in -python-native -DCPPPARSER -D__STDC__=1 -D__cplusplus -D__inline -longlong __int64 -D_X86_ -DWIN32_VC -DWIN32 -module libpandadna -library base -Dvolatile= config_dna.h dnabase.h DNALoader.h DNAStorage.h

Interrogate does not support #pragma once, so you have to use include guards to prevent the declaration from being picked up more than once.

I guess it would be nice for it to support #pragma once. I’ll look into this.

Just committed support for #pragma once.

The support is not fully functional. Suppose you have the files Loader, Group, Storage and the following dependency chain:

Loader -> Group -> Storage
-> Storage

You are interrogating Loader, Group and Storage, in that order.

Before your commit, interrogating Loader would fail because Storage is included in Loader and Group, which Loader includes as well.

Now, Loader works. However, when it’s time to interrogate Storage it fails since it has already been loaded in Loader. It feels like pragma once flag is reset or w.e.

Due to that, I’m temporarily changing all pragma onces in my project to old-style guards.

OK, I see the problem: it works when interrogating only Loader, but when interrogating the second file, interrogate resets the preprocessor state so parses it again.

This is actually the correct behaviour, but the problem is that it doesn’t forget the structure definitions from the previous file. That would be a difficult problem to correct. I’ll think more on this.

A workaround is to include all your headers from a single header and only interrogate that header file.