Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Friday, 24 April 2020, 05:22 PM
Please change SDK header fiels to contain #pragma once at start of file
Hi,

could you please in a following release foresee all headers of a #pragma once statement at the beginning of the header file?
I know this is probably not needed for the way you develop code, but we have other best practices and it would make life a lot easier. It doesn't hurt either for your way of working, and, it is a common practice.

Thx

Wim
2013
Moderator Registered 16 years 73 days
Guntram Diehl (innovaphone) Monday, 11 May 2020, 02:46 PM
Re: Please change SDK header fiels to contain #pragma once at start of file
Sorry this contradicts our best practises, so we won't change that.
Picture of Wim 4127
Registered 6 years 310 days
Wim 4127 Monday, 11 May 2020, 03:32 PM
Re: Please change SDK header fiels to contain #pragma once at start of file
Maybe consider header guards, which are for sure a common practice in C++ development and not compiler dependent:

Anyway, we worked around the issue to avoid the massive amount of redefinition errors one quickly gets without one of these. Other people that might encounter same issue can quickly construct an innovaphone.h file in their project with following content:
#pragma once
//Important: order does matter!
#include "platform/platform.h"
#include "common/os/iomux.h"
#include "common/interface/task.h"
#include "common/interface/socket.h"
#include "common/interface/webserver_plugin.h"
#include "common/interface/database.h"
#include "common/interface/json_api.h"
#include "common/ilib/str.h"
#include "common/ilib/json.h"
#include "common/interface/random.h"
#include "common/interface/pbx_admin.h"
#include "common/lib/appservice.h"
#include "common/lib/config.h"
#include "common/lib/tasks_postgresql.h"
#include "common/lib/appwebsocket.h"
#include "common/lib/app_updates.h"
#include "common/lib/badgecount_signaling.h"
After that, just use #include innovaphone.h which makes life easier.

Anyway, just something that would make life easier... case closed.
2013
Moderator Registered 16 years 73 days
Guntram Diehl (innovaphone) Monday, 11 May 2020, 03:35 PM
Re: Please change SDK header fiels to contain #pragma once at start of file
Yes you can solve it this way. We believe in well maintained include statements, which actually provide information about dependencies.
← You can define your color theme preference here