Hi, I am trying to integrate some utilities I have written for ArEventLog in a larger project. Everything compiles fine when I just include the file in the project. But when I try to reference this file in another file. I get the compile error:
declaration of C function ‘float atof(long unsigned int)’ conflicts with
35 Error 6/19/2024 10:46:48.4041 AM previous declaration ‘double atof(const char*)’ here Ln: 64 C:\BrAutomation\AS47\AS\GnuInst\V4.1.2\arm-elf\include\stdlib.h
I get other similar errors too. Does anyone know what could be the issue? My code in the utilities file is below:
#pragma once
//#include <bur/plctypes.h>
#include
#include
//#include <globaltyp.h>
//#include <globalvar.h>
#ifdef _DEFAULT_INCLUDES
#include <AsDefault.h>
#endif
namespace ArEventLogUtils
{
std::vector<std::string> store;
void LogMsg(const char* strMsg)
{
if (Step==40)
{
ArEventLogWrite_0.Ident = Ident;
ArEventLogWrite_0.EventID = 536870912;
ArEventLogWrite_0.OriginRecordID = 0;
ArEventLogWrite_0.ObjectID[0] = '3';
ArEventLogWrite_0.TimeStamp = 0;
ArEventLogWrite_0.AddData = (unsigned int)strMsg;
ArEventLogWrite_0.AddDataSize = strlen(strMsg)+1;
ArEventLogWrite_0.AddDataFormat = arEVENTLOG_ADDFORMAT_TEXT;
ArEventLogWrite_0.Execute = true;
ArEventLogWrite(&ArEventLogWrite_0); // synchron fub call
ArEventLogWrite_0.Execute = false;
ArEventLogWrite(&ArEventLogWrite_0); // synchron fub call
}
else
{
store.push_back(strMsg);
}
}
void ProcessMsgs()
{
for (int i = 0; i < store.size(); i++)
{
LogMsg(store[i].c_str());
}
store.clear();
}
void LogInit()
{
switch (Step)
{
case 0:
// Add Start Condition if nessesary
Step = 5;
break;
case 5:
ArEventLogGetIdent_0.Name[0] = 'a';
ArEventLogGetIdent_0.Execute = false;
ArEventLogGetIdent(&ArEventLogGetIdent_0);
Step = 10;
break;
case 10:
ArEventLogGetIdent_0.Execute = true;
ArEventLogGetIdent(&ArEventLogGetIdent_0);
if (ArEventLogGetIdent_0.Done)
{
Ident = ArEventLogGetIdent_0.Ident;
ArEventLogGetIdent_0.Execute = false;
Step = 30; // Write
}
else if (ArEventLogGetIdent_0.Error)
{
if (ArEventLogGetIdent_0.StatusID == arEVENTLOG_ERR_LOGBOOK_NOT_FOUND)
{
Step = 20; // create
ArEventLogCreate_0.Name[0] = 'a';
ArEventLogCreate_0.Size = 65535;
ArEventLogCreate_0.Persistence = arEVENTLOG_PERSISTENCE_PERSIST;
ArEventLogCreate_0.Info = 0;
ArEventLogCreate_0.Execute = false;
ArEventLogCreate(&ArEventLogCreate_0);
}
else
{
Step = 255; // error
}
}
break;
case 20:
ArEventLogCreate_0.Execute = true;
ArEventLogCreate(&ArEventLogCreate_0);
if (ArEventLogCreate_0.Done)
{
Ident = ArEventLogCreate_0.Ident;
ArEventLogCreate_0.Execute = false;
Step = 30; // Write
}
else if (ArEventLogCreate_0.Error)
{
Step = 255; // error
}
break;
case 30:
//LogMsg("my msg");
//LogMsg("additional msg");
Step = 40;
break;
case 40:
ProcessMsgs();
break;
}
}
}
If you have the “AsString” library in the project, you should switch to using “AsBrStr” library instead. Same for AsMath → AsBrMath and some other libraries.

The reason for this is that the functions declared in these libraries are conflicting with the C standard libraries, the library versions with “Br” in them do not conflict with the C standard library.
It should be straightforward to just use “Find and Replace in Files” to fix all the function calls. For example atof → brsatof, the function interface is identical.
Thanks, it looks like AsDefault.h file is generated and references the asstring.h file. Is there a way of using our defined global variables without referencing the AsDefault.h file?
I am not using any of the string functions. I am just using the ArEventLog functions and the variables of the ArEventLog types. I currently need to include the AsDefault.h file to use them.
Hi,
even if you don’t use functions out of AsString library, as long as it’s part of the project it will be also included by AsDefaultInclude mechanism. So please check if AsString is in your logical library package, and if yes and it’s not needed remove it from there.
If for whatever reason the AsString cannot be removed (e.g. because of dependencies of other libraries), you can disable the AsDefaultInclude mechanism - if doing that, then you have to include your references to header files in your C(++) code by using the whole relative path to the files of the project.
Please have a look to the following help page for details (in section “not using the default include mechanism”):
https://help.br-automation.com/#/en/4/programming%2Fmixiecandansic%2Fprogrammingmodel_mixiecandansic_include.html
Hope that helps,
best regards!
2 Likes
Thanks for your help. I avoided including the AsDefault.h file. I separated the files to also .h and .cpp and now it can be compiled and used.
Header file:
#pragma once
#include
#include
#include <globalVAR.h>
#ifdef _DEFAULT_INCLUDES
#endif
#include <ArEventLog.h>
namespace ArEventLogUtils
{
void LogMsg(const char* strMsg);
void ProcessMsgs();
void LogInit();
}
Source file:
#include “ArEventLogUtils.hpp”
namespace ArEventLogUtils
{
std::vectorstd::string store;
void LogMsg(const char* strMsg)
{
if (Step==40)
{
ArEventLogWrite_0.Ident = Ident;
ArEventLogWrite_0.EventID = 536870912;
ArEventLogWrite_0.OriginRecordID = 0;
ArEventLogWrite_0.ObjectID[0] = ‘3’;
ArEventLogWrite_0.TimeStamp = 0;
ArEventLogWrite_0.AddData = (unsigned int)strMsg;
ArEventLogWrite_0.AddDataSize = strlen(strMsg)+1;
ArEventLogWrite_0.AddDataFormat = arEVENTLOG_ADDFORMAT_TEXT;
ArEventLogWrite_0.Execute = true;
ArEventLogWrite(&ArEventLogWrite_0); // synchron fub call
ArEventLogWrite_0.Execute = false;
ArEventLogWrite(&ArEventLogWrite_0); // synchron fub call
}
else
{
store.push_back(strMsg);
}
}
void ProcessMsgs()
{
for (int i = 0; i < store.size(); i++)
{
LogMsg(store[i].c_str());
}
store.clear();
}
void LogInit()
{
switch (Step)
{
case 0:
// Add Start Condition if nessesary
Step = 5;
break;
case 5:
ArEventLogGetIdent_0.Name[0] = 'a';
ArEventLogGetIdent_0.Execute = false;
ArEventLogGetIdent(&ArEventLogGetIdent_0);
Step = 10;
break;
case 10:
ArEventLogGetIdent_0.Execute = true;
ArEventLogGetIdent(&ArEventLogGetIdent_0);
if (ArEventLogGetIdent_0.Done)
{
Ident = ArEventLogGetIdent_0.Ident;
ArEventLogGetIdent_0.Execute = false;
Step = 30; // Write
}
else if (ArEventLogGetIdent_0.Error)
{
if (ArEventLogGetIdent_0.StatusID == arEVENTLOG_ERR_LOGBOOK_NOT_FOUND)
{
Step = 20; // create
ArEventLogCreate_0.Name[0] = 'a';
ArEventLogCreate_0.Size = 65535;
ArEventLogCreate_0.Persistence = arEVENTLOG_PERSISTENCE_PERSIST;
ArEventLogCreate_0.Info = 0;
ArEventLogCreate_0.Execute = false;
ArEventLogCreate(&ArEventLogCreate_0);
}
else
{
Step = 255; // error
}
}
break;
case 20:
ArEventLogCreate_0.Execute = true;
ArEventLogCreate(&ArEventLogCreate_0);
if (ArEventLogCreate_0.Done)
{
Ident = ArEventLogCreate_0.Ident;
ArEventLogCreate_0.Execute = false;
Step = 30; // Write
}
else if (ArEventLogCreate_0.Error)
{
Step = 255; // error
}
break;
case 30:
//LogMsg("my msg");
//LogMsg("additional msg");
Step = 40;
break;
case 40:
ProcessMsgs();
break;
}
}
}
1 Like