Hey, i wrote a function getConfig that reads a file “config.conf” in one App.
Now i want to call that Function in another App using a .api file. I guess somethings wrong with my API file but i am not sure what. But after specifying the api file and compiling i get following error:
/home/reinhard/myLeafWorkspace/CL_Agents/Components/CL_ConfigComponent/CL_Config.c:26:6: error: conflicting types for ‘IF_Config_getConfig’
void IF_Config_getConfig(char* customerId,char* siteId, char* locationId, char* host, int* port, int* enableTls);
(Without the API file it compiles fine)
My API file looks like this:
FUNCTION int32 getConfig
(
string customerId[7] OUT,
string siteId[5] OUT,
string locationId[2] OUT,
string host[30] OUT,
int32 port OUT,
int32 enableTls OUT
);
Thanks in advance!
jyijyi
December 7, 2020, 9:15am
2
you can delete one by one to know which one makes the problem:
string customerId[7] OUT,
string siteId[5] OUT,
string locationId[2] OUT,
string host[30] OUT,
int32 port OUT,
int32 enableTls OUT
It seems to be all of them, when i change OUT to IN and change char* to const char* i stop getting that error but of course i don’t want to send the DAta in i want to get the data out.
The function is declared like:
int IF_Config_getConfig(char* customerId,char* siteId, char* locationId, char* host, int* port, int* enableTls);
jyijyi
December 7, 2020, 9:38am
4
From your previous discussion thread, the IPC_step4.rar already use both OUT and IN, but you say it is ok.
It works now! Thanks for your Help!
And here says string must be IN:
Oh, that’s because I changed it up for my needs and i only needed IN.
Where does it say that? Under “Specifying a Function” a OUT string is listed as an example.
I now tried passing the Data as struct and i get following error:
API:
STRUCT SWI_Config
{
string customerId[7];
string siteId[5];
string locationId[2];
string host[30];
int32 port;
int32 enableTls;
};
FUNCTION SWI_Config getConfig
(
);
Function:
IF_Config_SWI_Config_t IF_Config_getConfig();
Got it to work using struct.
Still thanks!
jyijyi
December 7, 2020, 10:58am
8
I found that you need to add one more parameter(message2Size) in the .c file in case you need to add OUT string:
void logger_logMessage
(
const char* message , ///< [IN]
char* message2,
size_t message2Size
)
{
LE_INFO( PREFIX_LOG_MSG "received the message \"%s\" from a client.",
message );
snprintf( message2, MESSAGE_SIZE,
"1234123412341324");
message2[ MESSAGE_MAX ] = '\0';
}
FUNCTION logMessage
(
string message[MSG_API_SIZE] IN,
string message2[MSG_API_SIZE] OUT
);
1 Like
Thanks that will be very useful!