Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » WARNINGS: LOG -> empty statement in RELEASE
WARNINGS: LOG -> empty statement in RELEASE [message #31834] Wed, 30 March 2011 11:09 Go to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
hi all, LOG yields some warning in if statements when RELEASE.
change to:
diff --git a/bazaar/Urr/Urr.h b/bazaar/Urr/Urr.h
index 3bec7c3..3ca50ac 100644
--- a/bazaar/Urr/Urr.h
+++ b/bazaar/Urr/Urr.h
@@ -32,7 +32,7 @@ inline int b_sendto(
 ) {
 	Sleep(rand() % 10);
 	int bug = rand() % 10;
-	if(bug == 0) LOG("[Emulated drop]");
+	if(bug == 0) { LOG("[Emulated drop]"); }
 	return bug ? sendto(s, buf, len, flags, to, tolen) : 0;
 }
 
diff --git a/uppsrc/Core/Debug.cpp b/uppsrc/Core/Debug.cpp
index fe4b239..9b469e9 100644
--- a/uppsrc/Core/Debug.cpp
+++ b/uppsrc/Core/Debug.cpp
@@ -230,7 +230,7 @@ void DeleteUsrLog()
 	}
 	else {
 		if(susrlog && !UsrLogStream().Delete())
-			LOG("Unable to delete UsrLog, " << GetLastErrorMessage());
+		{ LOG("Unable to delete UsrLog, " << GetLastErrorMessage()); }
 		susrlog = false;
 	}
 }

Re: WARNINGS: LOG -> empty statement in RELEASE [message #31836 is a reply to message #31834] Wed, 30 March 2011 13:14 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi kohait,

There is lot more warnings like this all over U++ Smile IMHO better solution (more general and future-proof) would be defining LOG as nonempty macro:
#ifndef flagDEBUG
#define LOG(X) {}
#endif 

I don't recall where the LOG is originally defined, but I'm sure you can find it Wink

Honza

[Updated on: Wed, 30 March 2011 13:15]

Report message to a moderator

Re: WARNINGS: LOG -> empty statement in RELEASE [message #31837 is a reply to message #31836] Wed, 30 March 2011 14:01 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
nice Smile good idea
Re: WARNINGS: LOG -> empty statement in RELEASE [message #31843 is a reply to message #31836] Wed, 30 March 2011 21:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
dolik.rce wrote on Wed, 30 March 2011 07:14

Hi kohait,

There is lot more warnings like this all over U++ Smile IMHO better solution (more general and future-proof) would be defining LOG as nonempty macro:
#ifndef flagDEBUG
#define LOG(X) {}
#endif 

I don't recall where the LOG is originally defined, but I'm sure you can find it Wink

Honza


Are you sure that GCC guys will not warn about "empty block" someday? Smile
Re: WARNINGS: LOG -> empty statement in RELEASE [message #31844 is a reply to message #31843] Wed, 30 March 2011 22:18 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Wed, 30 March 2011 21:43

Are you sure that GCC guys will not warn about "empty block" someday? Smile

If they do, we can make it "#define LOG(X) {int i=0;}", so later they can start warning us about "useless code block" Very Happy Then I would really start to consider using -Wno-empty-body (or -Wno-useless-code Smile ).

Honza
Re: WARNINGS: LOG -> empty statement in RELEASE [message #31848 is a reply to message #31844] Thu, 31 March 2011 09:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
dolik.rce wrote on Wed, 30 March 2011 16:18

mirek wrote on Wed, 30 March 2011 21:43

Are you sure that GCC guys will not warn about "empty block" someday? Smile

If they do, we can make it "#define LOG(X) {int i=0;}", so later they can start warning us about "useless code block" Very Happy Then I would really start to consider using -Wno-empty-body (or -Wno-useless-code Smile ).

Honza


This one would yield "unused variable" even today... Smile

I guess the one possible way around would be:

inline void Nop() {}

#define LOG(x) Nop()


Mirek
Re: WARNINGS: LOG -> empty statement in RELEASE [message #31855 is a reply to message #31848] Thu, 31 March 2011 10:25 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
tested: works and produces exact same executable in OPTIMAL.

diff --git a/uppsrc/Core/Defs.h b/uppsrc/Core/Defs.h
index 3f2bbca..a299889 100644
--- a/uppsrc/Core/Defs.h
+++ b/uppsrc/Core/Defs.h
@@ -16,6 +16,8 @@
 	#pragma setlocale("C")
 #endif
 
+inline void Nop() {}
+
 bool    IsPanicMode();
 
 void    Panic(const char *msg);
@@ -34,8 +36,8 @@ void    PanicMessageBox(const char *title, const char *text);
 
 #else
 
-#define ASSERT_(x, msg)
-#define ASSERT(x)
+#define ASSERT_(x, msg) UPP::Nop()
+#define ASSERT(x) UPP::Nop()
 
 #endif
 
diff --git a/uppsrc/Core/Diag.h b/uppsrc/Core/Diag.h
index 0c22914..93a43b5 100644
--- a/uppsrc/Core/Diag.h
+++ b/uppsrc/Core/Diag.h
@@ -135,35 +135,35 @@ inline void UnlockLog() {}
 #define DDUMPM(x)        @
 #define DTIMING(x)       @
 
-#define ASSERT(x)
+#define ASSERT(x) UPP::Nop()
 
-#define DEBUGCODE(x)
+#define DEBUGCODE(x) UPP::Nop()
 
 inline void LOGF(const char *format, ...) {}
 
-#define LOG(a)
-#define LOGBEGIN()
-#define LOGEND()
-#define LOGBLOCK(n)
-#define LOGHEXDUMP(s, a)
+#define LOG(a) UPP::Nop()
+#define LOGBEGIN() UPP::Nop()
+#define LOGEND() UPP::Nop()
+#define LOGBLOCK(n) UPP::Nop()
+#define LOGHEXDUMP(s, a) UPP::Nop()
 #define QUOTE(a)         a
-#define LOGSRCPOS()
-#define DUMP(a)
-#define DUMPC(a)
-#define DUMPCC(a)
-#define DUMPCCC(a)
-#define DUMPM(a)
-#define XASSERT(c, d)
-#define NEVER()
-#define NEVER_(msg)
-#define XNEVER(d)
+#define LOGSRCPOS() UPP::Nop()
+#define DUMP(a) UPP::Nop()
+#define DUMPC(a) UPP::Nop()
+#define DUMPCC(a) UPP::Nop()
+#define DUMPCCC(a) UPP::Nop()
+#define DUMPM(a) UPP::Nop()
+#define XASSERT(c, d) UPP::Nop()
+#define NEVER() UPP::Nop()
+#define NEVER_(msg) UPP::Nop()
+#define XNEVER(d) UPP::Nop()
 #define CHECK(c)         (c)
 #define XCHECK(c, d)     (c)
 
-#define TIMING(x)
-#define HITCOUNT(x)
-#define ACTIVATE_TIMING()
-#define DEACTIVATE_TIMING()
+#define TIMING(x) UPP::Nop()
+#define HITCOUNT(x) UPP::Nop()
+#define ACTIVATE_TIMING() UPP::Nop()
+#define DEACTIVATE_TIMING() UPP::Nop()
 
 #endif
 

Re: WARNINGS: LOG -> empty statement in RELEASE [message #31905 is a reply to message #31855] Tue, 05 April 2011 20:47 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
gcc release: still mourns Smile

C:\uppsvn\uppsrc/Core/Diag.h:142:0: warning: "ASSERT" redefined
C:\uppsvn\uppsrc/Core/Defs.h:38:0: note: this is the location of the previous definition
Re: WARNINGS: LOG -> empty statement in RELEASE [message #31921 is a reply to message #31905] Thu, 07 April 2011 10:52 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Should be fixed now...
Previous Topic: svn: patches, sandbox
Next Topic: FEAT: Tcl as a plugin
Goto Forum:
  


Current Time: Thu Mar 28 21:18:13 CET 2024

Total time taken to generate the page: 0.01181 seconds