You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by "Otto Fowler (Jira)" <ji...@apache.org> on 2021/12/15 17:42:00 UTC
[jira] [Created] (PLC4X-327) with-c doesn't build on macOS
Otto Fowler created PLC4X-327:
---------------------------------
Summary: with-c doesn't build on macOS
Key: PLC4X-327
URL: https://issues.apache.org/jira/browse/PLC4X-327
Project: Apache PLC4X
Issue Type: Bug
Reporter: Otto Fowler
Assignee: Otto Fowler
{code:c++}
#ifdef DEBUG_PLC4C_SYSTEM
#include <stdio.h>
printf("\n~~~~~~~~ PLC4C Connection ~~~~~~~~\n"
"Connection String:\t%s\n"
"Protocol Code:\t\t%s\n"
"Transport Code:\t\t%s\n"
"Connection Info:\t%s\n"
"Parameters:\t\t%s\n",
new_connection->connection_string ? new_connection->connection_string : "NULL",
new_connection->protocol_code ? new_connection->protocol_code : "NULL",
new_connection->transport_code ? new_connection->transport_code : "NULL",
new_connection->transport_connect_information ? new_connection->transport_connect_information : "NULL",
new_connection->parameters ? new_connection->parameters : "NULL");
#endif
{code}
This code causes an error because of the inclusion of stdio.h in the middle of the unit:
{code}
2 warnings generated.
[ 9%] Building C object spi/CMakeFiles/plc4c-spi.dir/src/subscribe.c.o
[ 10%] Building C object spi/CMakeFiles/plc4c-spi.dir/src/system.c.o
In file included from /Users/ottofowler/tmp/downloaded-plc4x-0.9.1rc2/0.9.1/rc2/apache-plc4x-0.9.1/plc4c/spi/src/system.c:298:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/stdio.h:260:54: error: function definition is not allowed here
__header_always_inline int __sputc(int _c, FILE *_p) {
^
1 error generated.
make[2]: *** [spi/CMakeFiles/plc4c-spi.dir/src/system.c.o] Error 1
make[1]: *** [spi/CMakeFiles/plc4c-spi.dir/all] Error 2
make: *** [all] Error 2
{code}
Section 7.1.2 Standard headers of the C standard says, in part:
If used, a header shall be included outside of any external declaration or definition, and it shall first be included before the first reference to any of the functions or objects it declares, or to any of the types or macros it defines.
So this isn't really right, I certainly don't think it is good practice in C.
We should hav two ifdef's one in the header section and one where the code is
--
This message was sent by Atlassian Jira
(v8.20.1#820001)