ottlukas opened a new issue, #633:
URL: https://github.com/apache/plc4x/issues/633
```
#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
```
This code causes an error because of the inclusion of stdio.h in the middle
of the unit:
```
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
```
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
Imported from Jira
[PLC4X-327](https://issues.apache.org/jira/browse/PLC4X-327). Original Jira may
contain additional context.
Reported by: otto.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]