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. Qt Creator with ecpg
Forum Updated to NodeBB v4.3 + New Features

Qt Creator with ecpg

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 854 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 Jakob Clausen

    Hi.

    I would like to use Qt Creator with ecpg, which is an embedded SQL preprocessor for C programs. It converts C programs with embedded SQL statements to normal C code by replacing the SQL invocations with special function calls.
    However clang also preprocesses the code and comes with warnings of the type Unknown type name for every sql thing I use.
    Screenshot from 2024-01-02 11-21-30.png
    Can I get rid of this without disabling clang?
    How should I do this? I have added the following lines to my .pro-file, which also seems a bit off.

    ecpgTarget.target = cfile
    ecpgTarget.commands = ecpg ../DatabaseBrowser/Database
    
    QMAKE_EXTRA_TARGETS += ecpgTarget
    PRE_TARGETDEPS = cfile
    
    Pl45m4P Offline
    Pl45m4P Offline
    Pl45m4
    wrote on last edited by Pl45m4
    #2

    @Jakob-Clausen said in Qt Creator with ecpg:

    Unknown type name for every sql thing I use.

    I have not any knowledge of ecpg, but are you really supposed to write it like this?!
    Doesn't ecpg need to run before you put that code in your cpp file?!
    As far as I understand, you need to pass some special .pcg file to ecpg and it outputs a C code file. So writing these SQL commands in the c / cpp file directly might not work?!


    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

    ~E. W. Dijkstra

    J 1 Reply Last reply
    0
    • Pl45m4P Pl45m4

      @Jakob-Clausen said in Qt Creator with ecpg:

      Unknown type name for every sql thing I use.

      I have not any knowledge of ecpg, but are you really supposed to write it like this?!
      Doesn't ecpg need to run before you put that code in your cpp file?!
      As far as I understand, you need to pass some special .pcg file to ecpg and it outputs a C code file. So writing these SQL commands in the c / cpp file directly might not work?!

      J Offline
      J Offline
      Jakob Clausen
      wrote on last edited by
      #3

      @Pl45m4 That is correct.
      The code that I have shown is from the .pcg file, and then ecpg preprocesses the code and generates a .c file, which can be compiled normally. The .pcg file is a c-file with some special ecpg-sql commands that are replaced by ecpg.
      But I would still like to use clang on the .pcg file, and then I get these warnings .

      Christian EhrlicherC JonBJ 2 Replies Last reply
      0
      • J Jakob Clausen

        @Pl45m4 That is correct.
        The code that I have shown is from the .pcg file, and then ecpg preprocesses the code and generates a .c file, which can be compiled normally. The .pcg file is a c-file with some special ecpg-sql commands that are replaced by ecpg.
        But I would still like to use clang on the .pcg file, and then I get these warnings .

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @Jakob-Clausen said in Qt Creator with ecpg:

        But I would still like to use clang on the .pcg file, and then I get these warnings .

        How should this work when there are special ecpg commands which are no c/c++ constructs in there?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        J 1 Reply Last reply
        1
        • J Jakob Clausen

          @Pl45m4 That is correct.
          The code that I have shown is from the .pcg file, and then ecpg preprocesses the code and generates a .c file, which can be compiled normally. The .pcg file is a c-file with some special ecpg-sql commands that are replaced by ecpg.
          But I would still like to use clang on the .pcg file, and then I get these warnings .

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #5

          @Jakob-Clausen
          If you put something like

          #if    0
          EXEC ...
          #endif
          

          around those lines, does that allow them to get through without upsetting clang/the IDE? Technically you're only allowed to put invalid C++ code even inside #if blocks, but sometimes tools just ignore it when false.

          If that works, you would need to have a symbol or expression you can test there which is false in editor but true while your SQL preprocessor is running. I'm sure you can find one --- it probably defines something itself which you could use.

          1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            @Jakob-Clausen said in Qt Creator with ecpg:

            But I would still like to use clang on the .pcg file, and then I get these warnings .

            How should this work when there are special ecpg commands which are no c/c++ constructs in there?

            J Offline
            J Offline
            Jakob Clausen
            wrote on last edited by Jakob Clausen
            #6

            @Christian-Ehrlicher It is ecpg commands mixed with ordinary c-code. So I would like to suppress that particular warning for that particular file.

            JonBJ 1 Reply Last reply
            0
            • J Jakob Clausen

              @Christian-Ehrlicher It is ecpg commands mixed with ordinary c-code. So I would like to suppress that particular warning for that particular file.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #7

              @Jakob-Clausen
              He & we know this. That doesn't make it possible for a C++ parser to parse the file correctly. And as you can see your warnings are pretty generic, you want to suppress "Unknown type" or "Missing ';'"?

              J 1 Reply Last reply
              0
              • JonBJ JonB

                @Jakob-Clausen
                He & we know this. That doesn't make it possible for a C++ parser to parse the file correctly. And as you can see your warnings are pretty generic, you want to suppress "Unknown type" or "Missing ';'"?

                J Offline
                J Offline
                Jakob Clausen
                wrote on last edited by
                #8

                @JonB I see your point. Could I disable clang for .pgc-files while still have some syntax highlighting? And then keep it as it is with .cpp files?

                JonBJ 1 Reply Last reply
                0
                • J Jakob Clausen

                  @JonB I see your point. Could I disable clang for .pgc-files while still have some syntax highlighting? And then keep it as it is with .cpp files?

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #9

                  @Jakob-Clausen That I don't know. But did you give a try to my earlier #if... suggestion?

                  J 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Jakob-Clausen That I don't know. But did you give a try to my earlier #if... suggestion?

                    J Offline
                    J Offline
                    Jakob Clausen
                    wrote on last edited by
                    #10

                    @JonB I did. And it did work. But I get no syntax highligthing. Maybe thats as good as it gets. So thank you for the input. I think I'll go with that.

                    JonBJ 1 Reply Last reply
                    0
                    • J Jakob Clausen has marked this topic as solved on
                    • J Jakob Clausen

                      @JonB I did. And it did work. But I get no syntax highligthing. Maybe thats as good as it gets. So thank you for the input. I think I'll go with that.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #11

                      @Jakob-Clausen said in Qt Creator with ecpg:

                      But I get no syntax highligthing

                      No syntax highlighting on what? On the EXEC SQL ... lines? That is the intention, else you will get the error! Qt Creator/clang is not going to "syntax highlight" those lines because they are not parseable C++! Not sure what else you would expect? I trust you do not mean that the rest of the C++ code, outside of the #if 0 blocks, lose their C++ highlighting?

                      J 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @Jakob-Clausen said in Qt Creator with ecpg:

                        But I get no syntax highligthing

                        No syntax highlighting on what? On the EXEC SQL ... lines? That is the intention, else you will get the error! Qt Creator/clang is not going to "syntax highlight" those lines because they are not parseable C++! Not sure what else you would expect? I trust you do not mean that the rest of the C++ code, outside of the #if 0 blocks, lose their C++ highlighting?

                        J Offline
                        J Offline
                        Jakob Clausen
                        wrote on last edited by
                        #12

                        @JonB No. You are right. Thank you.

                        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