Tweaked the debug building and printing a little - I hope this works OK for everyone. Let me know if not.
Tamped down a few warnings. For the demo/server Makefile, made an either/or choice between executable size optimization (normal) or gdb debug info and no optimization.
This commit is contained in:
@@ -41,7 +41,7 @@ DEBUGGING =
|
|||||||
OPTIMIZATION = -Os
|
OPTIMIZATION = -Os
|
||||||
ifeq (${BUILD},debug)
|
ifeq (${BUILD},debug)
|
||||||
OPTIMIZATION = -O0
|
OPTIMIZATION = -O0
|
||||||
DEBUGGING = -g
|
DEBUGGING = -g -DDEBUG_ENABLED=1
|
||||||
endif
|
endif
|
||||||
# put all the flags together
|
# put all the flags together
|
||||||
CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES)
|
CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES)
|
||||||
|
|||||||
@@ -903,7 +903,7 @@ int main(
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
BACNET_OBJECT_ID myObject;
|
BACNET_OBJECT_ID myObject;
|
||||||
uint8_t buffer[MAX_PDU] = { 0 };
|
uint8_t buffer[MAX_PDU] = { 0 };
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
BACNET_READ_ACCESS_DATA *rpm_object = NULL;
|
||||||
KEY nextKey;
|
KEY nextKey;
|
||||||
|
|
||||||
CheckCommandLineArgs(argc, argv); /* Won't return if there is an issue. */
|
CheckCommandLineArgs(argc, argv); /* Won't return if there is an issue. */
|
||||||
|
|||||||
@@ -37,19 +37,27 @@ LIBRARY1=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME)
|
|||||||
LIBRARY2=-lws2_32,-lgcc,-lm,-liphlpapi,-lwinmm
|
LIBRARY2=-lws2_32,-lgcc,-lm,-liphlpapi,-lwinmm
|
||||||
LIBRARIES=$(LIBRARY1),$(LIBRARY2)
|
LIBRARIES=$(LIBRARY1),$(LIBRARY2)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#build for release (default) or debug
|
#build for release (default) or debug
|
||||||
DEBUGGING =
|
|
||||||
OPTIMIZATION = -Os
|
|
||||||
ifeq (${BUILD},debug)
|
ifeq (${BUILD},debug)
|
||||||
|
# Use -g to put info for gdb in the executable
|
||||||
|
DEBUGGING = -g -DDEBUG_ENABLED=1
|
||||||
OPTIMIZATION = -O0
|
OPTIMIZATION = -O0
|
||||||
DEBUGGING = -g
|
LINK_OPTIMIZATION =
|
||||||
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
|
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
|
||||||
DEFINES += -DBIP_DEBUG
|
DEFINES += -DBIP_DEBUG
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
DEBUGGING =
|
||||||
|
# Use -f optimizations and then link option --gc-sections to reduce executable size.
|
||||||
|
# Of course, not when you want debug output for gdb!
|
||||||
|
OPTIMIZATION = -Os -fdata-sections -ffunction-sections
|
||||||
|
LINK_OPTIMIZATION = -Wl,--gc-sections
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# put all the flags together
|
# put all the flags together
|
||||||
CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES) -fdata-sections -ffunction-sections
|
CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES)
|
||||||
LFLAGS = -Wl,-Map=$(TARGET).map,$(LIBRARIES),--gc-sections
|
LFLAGS = -Wl,-Map=$(TARGET).map,$(LIBRARIES) $(LINK_OPTIMIZATION)
|
||||||
|
|
||||||
SRCS = main.c
|
SRCS = main.c
|
||||||
|
|
||||||
|
|||||||
@@ -43,16 +43,19 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#if DEBUG_ENABLED
|
|
||||||
void debug_printf(
|
void debug_printf(
|
||||||
const char *format,
|
const char *format,
|
||||||
...);
|
...);
|
||||||
|
#if DEBUG_ENABLED
|
||||||
|
/* Nothing more here */
|
||||||
#else
|
#else
|
||||||
static void debug_printf(
|
/* If your compiler supports it, this is more compact:
|
||||||
|
inline void debug_printf(
|
||||||
const char *format,
|
const char *format,
|
||||||
...) {
|
...) {
|
||||||
format = format;
|
format = format;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ DEBUGGING =
|
|||||||
WARNINGS = -Wall -Wmissing-prototypes
|
WARNINGS = -Wall -Wmissing-prototypes
|
||||||
ifeq (${BUILD},debug)
|
ifeq (${BUILD},debug)
|
||||||
OPTIMIZATION = -O0
|
OPTIMIZATION = -O0
|
||||||
DEBUGGING = -g
|
DEBUGGING = -g -DDEBUG_ENABLED=1
|
||||||
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
|
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
|
||||||
DEFINES += -DBIP_DEBUG
|
DEFINES += -DBIP_DEBUG
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -55,4 +55,10 @@ void debug_printf(
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void debug_printf(
|
||||||
|
const char *format,
|
||||||
|
...) {
|
||||||
|
format = format;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user