Skip to content

Commit

Permalink
Enable stream sanity checks in debug builds
Browse files Browse the repository at this point in the history
Enable this automatically for developers so we increase the chance of
these problems getting caught. There is a risk of overhead though so
keep them disabled for release builds.
  • Loading branch information
CendioOssman committed Apr 6, 2022
1 parent cee5a41 commit 99209d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -UNDEBUG")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -UNDEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -UNDEBUG")

# But extra debug checks are still gated by this custom define
IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG)
ENDIF()

# Make sure we get a sane C version
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")

Expand Down
4 changes: 3 additions & 1 deletion common/rdr/InStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

// Check that callers are using InStream properly,
// useful when writing new protocol handling
#undef RFB_INSTREAM_CHECK
#ifdef _DEBUG
#define RFB_INSTREAM_CHECK
#endif

namespace rdr {

Expand Down
4 changes: 0 additions & 4 deletions win/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/win)

configure_file(resdefs.h.in ${CMAKE_CURRENT_BINARY_DIR}/resdefs.h)

IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG)
ENDIF()

add_subdirectory(rfb_win32)

if(BUILD_WINVNC)
Expand Down

0 comments on commit 99209d0

Please sign in to comment.