Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions minsky_epilogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef MINSKY_EPILOGUE_H
#define MINSKY_EPILOGUE_H


#include "cairoSurfaceImage.h"
#if defined(CLASSDESC_RESTPROCESS_BASE_H)

Expand Down Expand Up @@ -163,3 +164,9 @@ namespace classdesc_access
}

#endif

// these macros are defined in XLib, but interfere with gtest, for example.
#undef True
#undef Bool
#undef None
Comment on lines +167 to +171

@coderabbitai coderabbitai Bot Oct 3, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Move macro undefs inside the header guard.

The #undef directives for True, Bool, and None are placed after the closing #endif of the header guard (line 166). This means they will be processed every time this header is included, even on subsequent includes when the header guard prevents the main content from being processed. This could lead to unintended macro removal if these macros are defined by headers included after this one.

Apply this diff to move the undefs inside the header guard:

 
 #endif
-
-// these macros are defined in XLib, but interfere with gtest, for example.
-#undef True
-#undef Bool
-#undef None
+
+// these macros are defined in XLib, but interfere with gtest, for example.
+#undef True
+#undef Bool
+#undef None
+
+#endif

Wait, let me reconsider. Looking at the line numbers again:

  • Line 166 has #endif
  • Lines 167-171 are the undefs

The undefs are currently AFTER the final #endif. They should be BEFORE it. Let me provide the correct diff:

+// these macros are defined in XLib, but interfere with gtest, for example.
+#undef True
+#undef Bool
+#undef None
+
 #endif
-
-// these macros are defined in XLib, but interfere with gtest, for example.
-#undef True
-#undef Bool
-#undef None
🤖 Prompt for AI Agents
In minsky_epilogue.h around lines 167 to 171, the #undef directives for True,
Bool, and None are placed after the header-guard closing #endif (line 166)
causing them to run on every inclusion; move those three #undef lines so they
appear just before the closing #endif of the header guard (i.e., inside the
guard) so the macros are only undefined when this header's contents are actually
processed.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I want - these macros should never be defined in the first place!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@highperformancecoder, thank you for the clarification! I understand now – you want these macros unconditionally undefined on every inclusion to prevent XLib macro pollution from interfering with gtest and other code. The placement after the header guard achieves exactly that. My apologies for the confusion!


3 changes: 0 additions & 3 deletions model/cairoItems.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#include <cairo/cairo.h>
#include "operation.h"
#include "variable.h"
#undef True
#undef Bool
#undef None

namespace minsky
{
Expand Down
2 changes: 1 addition & 1 deletion model/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ namespace minsky
ravelsToLock.push_back(r);
if (!lockGroup)
lockGroup=r->lockGroup;
if (lockGroup!=r->lockGroup)
if (r->lockGroup && lockGroup!=r->lockGroup)
conflictingLockGroups=true;
}
if (ravelsToLock.size()<2)
Expand Down
27 changes: 1 addition & 26 deletions test/00/t0022a.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,7 @@
#! /bin/sh

here=`pwd`
if test $? -ne 0; then exit 2; fi
tmp=/tmp/$$
mkdir $tmp
if test $? -ne 0; then exit 2; fi
cd $tmp
if test $? -ne 0; then exit 2; fi

fail()
{
echo "FAILED" 1>&2
cd $here
chmod -R u+w $tmp
rm -rf $tmp
exit 1
}

pass()
{
echo "PASSED" 1>&2
cd $here
chmod -R u+w $tmp
rm -rf $tmp
exit 0
}

trap "fail" 1 2 3 15
. test/common-test.sh

# check description/tooltip functionality
cat >input.py <<EOF
Expand Down
16 changes: 5 additions & 11 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ LIBS:=$(subst -lecolab,$(ECOLAB_HOME)/lib/libecolab.a,$(LIBS))

VPATH= .. ../schema ../model ../engine ../RESTService ../RavelCAPI/civita ../RavelCAPI $(ECOLAB_HOME)/include

UNITTESTOBJS=main.o testCSVParser.o testDerivative.o testExpressionWalker.o testGrid.o testLatexToPango.o testLockGroup.o testMdl.o testMinsky.o testModel.o testPannableTab.o testPhillips.o testPlotWidget.o testPubTab.o testSaver.o testStr.o testTensorOps.o testUnits.o testUserFunction.o testVariable.o testVariablePane.o testXVector.o ticket-1461.o

#GTESTOBJS=testCSVParserGtest.o
GTESTOBJS=testCSVParserGemini.o testCanvasGtest.o
GTESTOBJS=testCSVParser.o testCanvas.o testDerivative.o testExpressionWalker.o testGrid.o testLatexToPango.o testLockGroup.o testMdl.o testMinsky.o testModel.o testPannableTab.o testPhillips.o testPlotWidget.o testPubTab.o testSaver.o testStr.o testTensorOps.o testUnits.o testUserFunction.o testVariable.o testVariablePane.o testXVector.o ticket-1461.o

MINSKYOBJS=localMinsky.o ../libminsky.a
FLAGS:=-I.. -I../RESTService -I../RavelCAPI/civita -I../RavelCAPI $(FLAGS)
FLAGS+=-std=c++20 -DJSON_PACK_NO_FALL_THROUGH_TO_STREAMING -DUSE_UNROLLED -DCLASSDESC_ARITIES=0xf \
-Wno-unknown-warning-option -Wno-unused-local-typedefs -Wno-unused-command-line-argument -I../model -I../engine -I../schema
LIBS+=-L../RavelCAPI -lravelCAPI -L../RavelCAPI/civita -lcivita -lboost_system -lboost_thread \
-lboost_regex -lboost_date_time -lboost_filesystem -lclipboard -lxcb -lX11 \
-lUnitTest++ -lgsl -lssl -lcrypto -lgslcblas -lxml2 -ltiff -ldl
-lgsl -lssl -lcrypto -lgslcblas -lxml2 -ltiff -ldl

ifdef MXE
else
Expand All @@ -45,12 +42,9 @@ ifdef ASAN
FLAGS+=-fsanitize=address -fno-omit-frame-pointer
endif

all: unittests gtestUnittests $(EXES)

unittests: $(UNITTESTOBJS) $(MINSKYOBJS)
$(CPLUSPLUS) $(FLAGS) -o $@ $^ $(LIBS)
all: unittests $(EXES)

gtestUnittests: gtestUnittests.o $(GTESTOBJS) $(MINSKYOBJS)
unittests: gtestUnittests.o $(GTESTOBJS) $(MINSKYOBJS)
$(CPLUSPLUS) $(FLAGS) -o $@ $^ $(LIBS) -lgtest

# todo - remove dependency on all MINSKYOBJS
Expand All @@ -73,7 +67,7 @@ tcl-cov: tcl-cov.o $(MINSKYOBJS)
$(CPLUSPLUS) $(FLAGS) -o $@ $^ $(LIBS)

ifneq ($(MAKECMDGOALS),clean)
include $(UNITTESTOBJS:.o=.d) $(EXES:=.d)
include $(UNITTESTOBJS:.o=.d) $(GTESTOBJS:.o=.d) $(EXES:=.d)
endif

BASIC_CLEAN=rm -rf *.o *~ "\#*\#" core *.d *.cd *.xcd *.gcda *.gcno
Expand Down
2 changes: 1 addition & 1 deletion test/common-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ pass()
trap "fail" 1 2 3 15

# add here to PYTHONPATH to find local build of pyminsky
export PYTHONPATH=$here:$PYTHONPATH
export PYTHONPATH="$here:$PYTHONPATH"
export LD_LIBRARY_PATH=$here/ecolab/lib:$LD_LIBRARY_PATH
98 changes: 0 additions & 98 deletions test/main.cc

This file was deleted.

Loading
Loading