There is a * .h file with the following code:
#ifndef CORECOMMANDS_H #define CORECOMMANDS_H #pragma once #include <QString> #include <QStringList> struct MassageDataIn{ QString operationId; QStringList names; QStringList values; }; //袟邪锌褉芯褋 斜邪蟹芯胁褘褏 锌邪褉邪屑械褌褉芯胁 褟写褉邪 const MassageDataIn cmdSetupRequest(){ MassageDataIn massageData; massageData.operationId = "12"; return massageData; } //袟邪锌褉芯褋 褋芯褋褌芯褟薪懈褟 褟写褉邪 const MassageDataIn cmdSync(){ MassageDataIn massageData; massageData.operationId = "11"; return massageData; } This file was written in the console application and worked without any errors. After creating the console application, it became necessary to use it in the QWidget application already. When I try to compile the project at the initial stage (I just created a standard QWidget project and connected this and several more files, after copying it from the console project), I get an error:
14: error: multiple definition of 'cmdSetupRequest ()' UI \ corecommands.h: 14: first defined here UI \ debug \ core.o: -1: In function `Z7cmdSyncv ':
On the forum I read that adding inline and extern solve this problem and it really is. BUT! Why is it possible to do without them in the console application, but not in QWidget ? If you still can correct these errors without adding inline and extern how can this be done.
ps pragma once in all * .h files