Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Warning: C4251
Qt 6.11 is out! See what's new in the release blog

Warning: C4251

Scheduled Pinned Locked Moved General and Desktop
24 Posts 4 Posters 17.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ZapB
    wrote on last edited by
    #15

    And can you post the header of the class which does the #include of the above please? At this stage it looks as if you need to export the DataItem class from your dll too.

    Nokia Certified Qt Specialist
    Interested in hearing about Qt related work

    1 Reply Last reply
    0
    • H Offline
      H Offline
      huckfinn
      wrote on last edited by
      #16

      Yes, here you are:
      @
      #ifndef ModuleData_H
      #define ModuleData_H

      // inherits
      #include <QtCore/QThread>
      #include "QtDemoModule.h"

      // instantiates
      #include <QtGui/QStandardItemModel>
      #include "SignalCondition.h"
      #include <StateMachine.h>
      #include <QtCore/QWaitCondition>

      #include <QObject>
      #include <QList>
      #include <DataInfo.h>

      // here my stuff
      //#include "DataItem.h"

      class ModuleLoader;
      class DataHandler;
      class EventHandler;
      class ModuleDockWidget;
      class QModelIndex;

      class ModuleData
      : public QtDemoModule
      , public QThread
      {
      public:

          /// @brief Constructor
          ModuleData( void );
      
          /// @brief Destructor
          virtual ~ModuleData( void );
      
          /// @brief For getting singalton instance of this class.
          static ModuleData *GetInstance( void );
      
          /// @brief Called by the DLL interface on startup
          void Startup( ModuleLoader &rLoader );
      
          /// @brief Called by the DLL interface on shutdown
          void Shutdown( void );
      
      // inherited from EventChecker
      public:
      
          /// @brief handle incoming events like mouse movement
          virtual bool EventOccurred( quint32 eventID );
      
      // inherited from MsgChecker
      public:
      
          /// @brief Called on incoming message.
          /// This method is inherited from MsgChecker
          virtual void HandleMessage( const MsgHandler c_msg );
      
          /// @brief Called on runlevel changes.
          /// This method is inherited from MsgChecker
          virtual quint32 HandleRunlevel( const quint32 c_runlevel, const qint8 c_direction );  
      
          /// @brief Called by messenger to publish interfaces.
          /// This method is inherited from MsgChecker
          virtual void HandleInterface( const quint32 interfaceId, const quint32 version, const quint32 validRunlevel, void * const pObj );
      
      // inherited by QtDemoModule
      public:
      
          virtual QDockWidget * setup_gui( QWidget *pParent );
      
          /// @brief Implement this method to do things after started
          virtual void init( RadioScannerInterface * );
      
          /// @brief this method will be called before the Crunner will be shut down
          virtual void deinit( void );
      

      /// Display Data currently on display if visible
      void displayData(qint32 DataType, qint32 xData, qint32 yData);

      /// Draw Edge via its id
      void drawEdge(qint32 edgeId);

      /// Clear Edges
      void clearEdges();

      // calc field to active Data - outcomment by my side
      //void calc_field_to_Data(const DataItem * tPI);
      //bool set_m_listfieldCalcDatas(const DataItem * tPI);

      // Prepare and stop calculation
      bool prepareCalculation();
      bool field_simulation_active();
      void stop_field_simulation();

      private:
      
          /// @brief does the actual reading of the Data details
          virtual void run( void );
      
          /// @brief
          void loadCategoryNames( void );
      
          /// @brief
          void importDatas( void );
      
      private:
      
          /// different Data trees you can address
          enum DataTreeMode 
          {
              GENERIC = 0,
              PREFERRED_DATAS = 1,
              DATAS_ALONG_THE_FIELD = 2,
              DATAS_ON_THE_FIELD = 3
          };
      
          /// Data search result item
          struct DataSearchResult 
          {
              QString m_DataName;
              int     m_DataType;
          };
      

      /// Categorie by name, mapped to its CAT ID
      QMap< int, QString > m_categoryNameByID;

      /// Preparation Ordered edges according to current field
      void prepare_extraction_current_fields_edgeIDs();
      /// Extraction Ordered edges according to current field
      void extract_current_fields_edgeIDs();

      ///
      QList<DFieldInfo> m_listfieldCalcDatas; ///< List of field calculation positions.

          /// SignalConditions
      

      SignalCondition m_signalfieldListExtraction; ///< Signal to wait for result of event GET_FIELD_LIST.
      SignalCondition m_signalfieldReset; ///< Signal to wait for result of event GET_LIST_RESET.

          bool m_fieldCalcSuccess; ///< Flag to represent field calculation was successful or not.
      

      bool m_fieldSimulationActive; ///< Flag to represent that field calculation is active or not

          /// Datanter to this module's main dock window 
          CDataDockWidget *m_pDockWidget; 
      
          /// interface to the data pool.
          DataHandler *m_pDataHandler;
      
          ///  interface to the event system. 
          EventHandler *m_pEventHandler; 
      
          ///  interface to the RF
          Crunner *m_pCrunnerRF; 
      
          /// current runlevel direction will be stored 
          qint8 m_direction;
      
          /// the mode the map was rendered
          qint32 m_renderMode;
      
          /// this will store the enabled/disabled state for each Data category
          QStandardItemModel m_model;
      
          QWaitCondition m_condition_Data_query;
      
          QMutex m_condition_Data_query_mutex;
      
          /// flag indicating that the query thread has to be stopped
          bool m_cancel;
      
          //the resolution of the drawn map
          qint32 m_mapResolution;
      
          //stores the Data search results
          QList<DataSearchResult> m_DataSearchResults;
      
          /// the size in pixels of the Data icon
          static const qint32 C_Data_ICON_SIZE;
      
      // static elements
      private:
      
          /// Singleton instance of this class
          static ModuleData *m_pInstance; 
      

      };
      #endif
      @

      Just including //#include "DataItem.h" without using it, causes the warnings above..

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #17

        You don't seem to be exporting this class either. You need to export these classes from the dll in order to be able to use them in applications that link against it.

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • H Offline
          H Offline
          huckfinn
          wrote on last edited by
          #18

          I've tried it, in vain:

          ModuleData.h
          @
          #include "DataItem.h"

          #if defined(SWITCH)

          define MODULE_DATA_EXP Q_DECL_EXPORT

          #else

          define MODULE_DATA_EXP Q_DECL_IMPORT

          #endif

          class ModuleLoader;
          class DataHandler;
          class EventHandler;
          class ModuleDockWidget;
          class QModelIndex;

          class MODULE_DATA_EXP ModuleData
          {
          //...
          @
          and in DataItem.h
          @
          #if defined(SWITCH)

          define DATA_ITEM_EXP Q_DECL_EXPORT

          #else

          define DATA_ITEM_EXP Q_DECL_IMPORT

          #endif

          class DATA_ITEM_EXP DataItem
          {
          //...
          @

          1 Reply Last reply
          0
          • H Offline
            H Offline
            huckfinn
            wrote on last edited by
            #19

            Anybody any hints?

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on last edited by
              #20

              Try either:

              • Start a new shared library project and start adding your code to it until you see this error
              • Start stripping stuff out of your existing library until you don't see the error.

              Either way be sure to export the necessary classes from your shared library and import them into your application.

              Often making a small and simple test case that reproduces the problem makes it much easier to find the solution which you often do in the process of making the test case.

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply
              0
              • H Offline
                H Offline
                huckfinn
                wrote on last edited by
                #21

                I started a new .dll with Qt Creator and there I have example.cpp and a example.h.
                Additionally a file named example_global.h has been automatically generated, where following is defined:
                @
                #if defined(DDDG_LIBRARY)

                define DDDGSHARED_EXPORT Q_DECL_EXPORT

                #else

                define DDDGSHARED_EXPORT Q_DECL_IMPORT

                #endif
                @
                and in the example.h there is:
                @
                #include "dddg_global.h"
                class DDDGSHARED_EXPORT Dddg {
                //...
                @

                In my project I do not have such a global header file. I entered this export stuff

                @
                #if defined(DDDG_LIBRARY)

                define DDDGSHARED_EXPORT Q_DECL_EXPORT

                #else

                define DDDGSHARED_EXPORT Q_DECL_IMPORT

                #endif
                @

                in each header where I got those warnings (each with different nomenclature).
                So I assume I misunderstood the export functionality. I need one global header with that Q_DECL_EXPORT stuff, an each other class-header needs a
                @
                #include "dddg_global.h"
                class DDDGSHARED_EXPORT Dddg {
                //...
                @
                ? When I create such a global header manually, how do I configure the properties settings, that the compiler recognize this header as such a global header? Or is this automatically when I include that in each header?
                Or this is regardless and both ways are possible?

                Cheers Huck

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  ZapB
                  wrote on last edited by
                  #22

                  A header is a header is a header. There is nothing special about it apart from that it contains only the export/import macros.

                  As you say, just include it in each class and add DDDGSHARED_EXPORT before each class that you wish (or need) to export and all should be good.

                  I tend to name the macro something like DDDGSHARED_API so as not to fool myself into thinking that it always resolves to Q_DECL_EXPORT but that's just for the benefit of my poor little brain.

                  As a side note, to enable symbol visibility with gcc you need to add

                  @
                  CONFIG += hide_symbols
                  @

                  to your .pro file. I'm not sure why this is not enabled by default for gcc nowadays.

                  Nokia Certified Qt Specialist
                  Interested in hearing about Qt related work

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    huckfinn
                    wrote on last edited by
                    #23

                    Add CONFIG += hide_symbols to your .pro file?

                    Unfortunately, I do not use gcc. It is the VC++ Compiler version 9 I think.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on last edited by
                      #24

                      I was just mentioning it in case you ever decide to use GCC.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved