Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. qt qxorm qml not supor files .c
Forum Updated to NodeBB v4.3 + New Features

qt qxorm qml not supor files .c

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 408 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.
  • J Offline
    J Offline
    jchaviano
    wrote on last edited by Chris Kawa
    #1

    In another post that I made, they did not give me a solution and I am desperate. The problem is the following: I am making a qml application with qxorm that works correctly. I need to add a subproject that is in its C malloria, but qxorm simply by adding a .c file stops working. The error is that it stops recognizing classes like iostream and others. My question is the following. Should I assume that it is not compatible with C or I am simply doing something wrong?

    qtimagenes.png

    qtimagenes2.png

    In this image you can see that without using the .c file it compiles correctly, clarify that it is just a simple project to illustrate the error seen in the previous photos
    qtimagenes3.png

    This is the .pro with the file that causes me an error. clarify that it happened to me with any .c not only with this file. I think that even with the empty file the app stops working

    the .pro file

    QT += quick
    
    CONFIG += c++11
    
    #qxorm ok init
    include(../QxOrm/QxOrm.pri)
    TEMPLATE = app
    DEFINES += _BUILDING_QX_BLOG
    INCLUDEPATH += ../QxOrm/include/
    DESTDIR = $$PWD/_bin/
    LIBS += -L"$$PWD/libQxormx32"
    
    CONFIG(debug, debug|release) {
    TARGET = TecnoUnlockerDb
    LIBS += -l"QxOrmd"
    } else {
    TARGET = TecnoUnlockerDb
    LIBS += -l"QxOrm"
    } # CONFIG(debug, debug|release)
    
    !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
    PRECOMPILED_HEADER = ./include/precompiled.h
    } # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
    #qxorm ok end
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
            classproyects/conectmongodb.cpp \
            main.cpp \
            mi_c_file.c # This file is the one that damages the app 
    
    RESOURCES += qml.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Additional import path used to resolve QML modules just for Qt Quick Designer
    QML_DESIGNER_IMPORT_PATH =
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
        classproyects/conectmongodb.h \
        include/author.h \
        include/export.h
    
    Chris KawaC 1 Reply Last reply
    0
    • J jchaviano

      In another post that I made, they did not give me a solution and I am desperate. The problem is the following: I am making a qml application with qxorm that works correctly. I need to add a subproject that is in its C malloria, but qxorm simply by adding a .c file stops working. The error is that it stops recognizing classes like iostream and others. My question is the following. Should I assume that it is not compatible with C or I am simply doing something wrong?

      qtimagenes.png

      qtimagenes2.png

      In this image you can see that without using the .c file it compiles correctly, clarify that it is just a simple project to illustrate the error seen in the previous photos
      qtimagenes3.png

      This is the .pro with the file that causes me an error. clarify that it happened to me with any .c not only with this file. I think that even with the empty file the app stops working

      the .pro file

      QT += quick
      
      CONFIG += c++11
      
      #qxorm ok init
      include(../QxOrm/QxOrm.pri)
      TEMPLATE = app
      DEFINES += _BUILDING_QX_BLOG
      INCLUDEPATH += ../QxOrm/include/
      DESTDIR = $$PWD/_bin/
      LIBS += -L"$$PWD/libQxormx32"
      
      CONFIG(debug, debug|release) {
      TARGET = TecnoUnlockerDb
      LIBS += -l"QxOrmd"
      } else {
      TARGET = TecnoUnlockerDb
      LIBS += -l"QxOrm"
      } # CONFIG(debug, debug|release)
      
      !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
      PRECOMPILED_HEADER = ./include/precompiled.h
      } # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
      #qxorm ok end
      
      DEFINES += QT_DEPRECATED_WARNINGS
      
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      SOURCES += \
              classproyects/conectmongodb.cpp \
              main.cpp \
              mi_c_file.c # This file is the one that damages the app 
      
      RESOURCES += qml.qrc
      
      # Additional import path used to resolve QML modules in Qt Creator's code model
      QML_IMPORT_PATH =
      
      # Additional import path used to resolve QML modules just for Qt Quick Designer
      QML_DESIGNER_IMPORT_PATH =
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      HEADERS += \
          classproyects/conectmongodb.h \
          include/author.h \
          include/export.h
      
      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      @jchaviano Files with .c extension are treated as C language files and are compiled by C compiler. iostream is a C++ header and you can't use it in a C file. You have a precompiled header that is included in all your files and it includes <iostream> and bunch of other C++ headers.

      You have several options to fix this. You could stop using precompiled headers. You could create another library project just for C files. You could remove C++ includes from the precompiled header. Or, the easiest I think, would be to just enclose all C++ headers in the precompiled.h like this:

      #ifdef __cplusplus
      
      #include <iostream>
      #include <algorithm>
      ... the rest of C++ headers
      
      #endif
      

      This way your precompiled header will work for both C and C++.

      J 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        @jchaviano Files with .c extension are treated as C language files and are compiled by C compiler. iostream is a C++ header and you can't use it in a C file. You have a precompiled header that is included in all your files and it includes <iostream> and bunch of other C++ headers.

        You have several options to fix this. You could stop using precompiled headers. You could create another library project just for C files. You could remove C++ includes from the precompiled header. Or, the easiest I think, would be to just enclose all C++ headers in the precompiled.h like this:

        #ifdef __cplusplus
        
        #include <iostream>
        #include <algorithm>
        ... the rest of C++ headers
        
        #endif
        

        This way your precompiled header will work for both C and C++.

        J Offline
        J Offline
        jchaviano
        wrote on last edited by
        #3

        @Chris-Kawa qtimagenes5.png

        This solution gives me other errors.

        Chris KawaC 1 Reply Last reply
        0
        • J jchaviano

          @Chris-Kawa qtimagenes5.png

          This solution gives me other errors.

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          @jchaviano I said enclose all C++ headers, not just standard C++ library headers. Notice that you have Qt headers below that. Qt is a C++ library. You can't use it in C files either. I'm betting everything in that precompiled.h is C++ so you might as well enclose all of it.

          By the way - you don't have to include every single Qt header from QtCore (or any other module) individually. You can just #include <QtCore> and it will get all of them.

          J 1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            @jchaviano I said enclose all C++ headers, not just standard C++ library headers. Notice that you have Qt headers below that. Qt is a C++ library. You can't use it in C files either. I'm betting everything in that precompiled.h is C++ so you might as well enclose all of it.

            By the way - you don't have to include every single Qt header from QtCore (or any other module) individually. You can just #include <QtCore> and it will get all of them.

            J Offline
            J Offline
            jchaviano
            wrote on last edited by
            #5

            @Chris-Kawa

            I stopped using the precompiled headers since the others that you mentioned to me generate more errors.
            qtimagenes6.png

            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