vsqlite-- icon indicating copy to clipboard operation
vsqlite-- copied to clipboard

The function `emit` shadows Qt's emit functionality

Open nullptrT opened this issue 6 years ago • 2 comments

The function emit works without Qt and Qt works without vsqlite++. When using both together, you get the following compiler error:

In file included from src/./vsqlite++/include/sqlite/execute.hpp:35,
                 from src/./database.hpp:5,
                 from src/./todo.hpp:8,
                 from src/gui/mainwindow.cpp:9:
src/vsqlite++/include/sqlite/command.hpp:80:19: error: expected unqualified-id before ‘)’ token
         bool emit();

A simple renaming of the function emit(), which just forwards step(), in vsqlite++ solves this error.

Is there any reason for sqlite::command::emit or will it stay equal to sqlite::command::step?

nullptrT avatar Feb 13 '19 18:02 nullptrT

No, there's no reason it was called 'emit' - However changing this would break the API for anyone ever using emit, which is kind of unfortunate.

Then again Qt Sql does support sqlite out of the box, wouldn't it be easier to use that one?

I am not sure of a solution for this except for renaming the method, which would break a quite stable API and also an ABI.

I am open to hear about other possible workarounds

vinzenz avatar Feb 15 '19 17:02 vinzenz

Qt supports disabling its signals and slots macros, by adding CONFIG += no_keywords in the qproject file, or passing directly a define or macro to the compiler.

You must then use Q_SIGNAL, Q_EMIT, Q_SLOT.

See https://doc.qt.io/qt-5/signalsandslots.html#using-qt-with-3rd-party-signals-and-slots

janderudder avatar Sep 11 '21 16:09 janderudder