turn off Cocos2D verbose logging - ios

I just upgraded to cocos 2.1, and am seeing a ridiculous amount of logging to the console, such as:
2013-09-18 23:15:38.120 Notes and Clefs[842:907] cocos2d: deallocing <CCSprite = 0x1182aa0 | Rect = (816.00,640.00,32.00,64.00) | tag = -1 | atlasIndex = -1>
2013-09-18 23:15:38.121 Notes and Clefs[842:907] cocos2d: deallocing <CCSprite = 0x1182600 | Rect = (816.00,128.00,32.00,64.00) | tag = -1 | atlasIndex = -1>
2013-09-18 23:15:38.122 Notes and Clefs[842:907] cocos2d: deallocing <CCArray = 0x1161e00> = ( <CCSprite = 0x1182790 | Rect = (816.00,640.00,32.00,64.00) | tag = -1 | atlasIndex = -1>, )
etc..
From looking at the code, I see:
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
And I set COCOS2D_DEBUG = 0, but I still get the same verbose logging...
I have Cocos2D in my project as a static library .a file.. Is it possible that this .a already has a macro/constant defined at level 2 or something, and that's why I'm seeing it not make any difference?
Can anyone recommend a way to turn this off?

Yes, when the static library is compiled using the Debug scheme, it'll print all these debug messages out. Try recompiling the static library with the COCOS2D_DEBUG preprocessor macro set to 1.
Why are you adding it as a static .a library though? I just add the cocos2d-ios.xcodeproj to my own project and add libcocos2d.a to Build Phases under Link Binary with Libraries. That way it'll automatically recompile cocos2d whenever a change occurs.

Related

PPPoS configurations for the lwIP Stack

I am working on the lwIP stack with the ATSAMV71 microcontroller.
I would like to configure the lwIP stack in PPPoS mode using a TCP/IP connection.
Will you please help me to know,
What is required #define the configurations required to put the lwIP stack into PPPoS mode?
/*
---------------------------------
---------- PPP options ----------
---------------------------------
*/
#define PPP_SUPPORT 1
#define PAP_SUPPORT 1
#define LWIP_DNS 1
/*
---------------------------------
--------- GPRS options ----------
---------------------------------
*/
#define GPRS_DEBUG LWIP_DBG_OFF
#define GPRS_SUPPORT 1
#define GPRS_TYPE 1
#define GPRS_OWNTHREAD 1
#define GPRS_THREAD_NAME "pppos"
#define GPRS_RUNTIME_APN 1
#define GPRS_RUNTIME_PIN 1
#define GPRS_COMMAND_DELAY 500
#define GPRS_ICCID 1
#define GPRS_THREAD_STACKSIZE 512
#define GPRS_THREAD_PRIO 2
#define GPRS_PPPIF_NAME_0 'P'
#define GPRS_PPPIF_NAME_1 '0'

How do I go build a Go GTK 2 app for Windows from Linux? Is there a Docker image?

I am trying to cross-compile a .go file for the GTK binding package Linux => Windows and can't figure it out. Tried going the route of setting up MSYS on Win but it was god-awful.
I looked for a Docker image but there is none.
$ ~/go/src/gui$ GOOS=windows CGO_ENABLED=1 GOARCH= CC=x86_64-w64-mingw32-gcc go build
# github.com/mattn/go-gtk/glib
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./glib.go.h:4,
from ../github.com/mattn/go-gtk/glib/glib.go:5:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:241:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:238:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:241:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
^~~~~~~~~~~~~~~
# github.com/mattn/go-gtk/pango
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/pango-1.0/pango/pango-coverage.h:25,
from /usr/include/pango-1.0/pango/pango-font.h:25,
from /usr/include/pango-1.0/pango/pango-attributes.h:25,
from /usr/include/pango-1.0/pango/pango.h:25,
from ./pango.go.h:7,
from ../github.com/mattn/go-gtk/pango/pango.go:5:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:241:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:238:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:241:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));```

How to tell Autoconf "require symbol A or B" from LIB?

I'm trying to configure Postgres 9.5.4 for OpenSSL 1.1.0. Configure is dying because it can't find SSL_library_init in OpenSSL 1.1.0. OpenSSL 1.1.0 provides OPENSSL_init_ssl instead of SSL_library_init. So Autoconf needs to check for either SSL_library_init or OPENSSL_init_ssl.
Postgres uses the following test:
AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
How do I modify that [rule?] to look for either SSL_library_init or OPENSSL_init_ssl?
Naively, I changed configure.in to the following, which did not work. The best I can tell, my changes were ignored (even after running autoreconf):
AC_CHECK_LIB(ssl, SSL_library_init|OPENSSL_init_ssl, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
Here is the Postgrs configure command:
$ ./configure --with-openssl --with-includes=/usr/local/ssl/include --with-libraries=/usr/local/ssl/lib
Here is the relevant entry from config.log:
configure:8732: gcc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-Wno-unused-command-line-argument -I/usr/local/ssl/include
-L/usr/local/ssl/lib -I/usr/local/ssl/include -L/usr/local/ssl/lib
conftest.c -lssl -lcrypto -lz -lreadline -lm >&5
Undefined symbols for architecture x86_64:
"_SSL_library_init", referenced from:
_main in conftest-c0c2a1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
configure:8732: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "PostgreSQL"
| #define PACKAGE_TARNAME "postgresql"
| #define PACKAGE_VERSION "9.5.4"
| #define PACKAGE_STRING "PostgreSQL 9.5.4"
| #define PACKAGE_BUGREPORT "pgsql-bugs(at)postgresql(dot)org"
| #define PACKAGE_URL ""
| #define PG_MAJORVERSION "9.5"
| #define PG_VERSION "9.5.4"
| #define USE_INTEGER_DATETIMES 1
| #define DEF_PGPORT 5432
| #define DEF_PGPORT_STR "5432"
| #define BLCKSZ 8192
| #define RELSEG_SIZE 131072
| #define XLOG_BLCKSZ 8192
| #define XLOG_SEG_SIZE (16 * 1024 * 1024)
| #define ENABLE_THREAD_SAFETY 1
| #define PG_KRB_SRVNAM "postgres"
| #define USE_OPENSSL 1
| #define HAVE_LIBM 1
| #define HAVE_LIBREADLINE 1
| #define HAVE_LIBZ 1
| #define HAVE_SPINLOCKS 1
| #define HAVE_ATOMICS 1
| #define HAVE_LIBCRYPTO 1
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char SSL_library_init ();
| int
| main ()
| {
| return SSL_library_init ();
| ;
| return 0;
| }
configure:8741: result: no
configure:8751: error: library 'ssl' is required for OpenSSL
Something like this should work out for you:
ACCEPT_SSL_LIB="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [ACCEPT_SSL_LIB="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [ACCEPT_SSL_LIB="yes"])
AS_IF([test "x$ACCEPT_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
You may need another variable to tell you what init function to call, to set up SSL, unless there's some macro magic in a header file that will actually fix it up to the right value.
To build upon #ldav1s' answer, here are the changes to configure.in required to get past configuration. Once configure.in is modified, autoreconf should be run.
$ git diff configure.in > configure.in.diff
$ cat configure.in.diff
diff --git a/configure.in b/configure.in
index c878b4e..7ba7538 100644
--- a/configure.in
+++ b/configure.in
## -1112,10 +1112,16 ## if test "$with_openssl" = yes ; then
dnl Order matters!
if test "$PORTNAME" != "win32"; then
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
- AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
+ FOUND_SSL_LIB="no"
+ AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
+ AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
+ AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
else
AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
- AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
+ FOUND_SSL_LIB="no"
+ AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
+ AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
+ AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
fi
AC_CHECK_FUNCS([SSL_get_current_compression])
fi

What does this error mean and how exactly can we fix it because the example tonemelody program works fine?

enter code here
#include "Pitches.h"
// notes in the melody:
int melody[] = {
NOTE_FS4, NOTE_FS4, NOTE_D4, NOTE_B3,0, NOTE_B3,0, NOTE_E4,0, NOTE_E4,0,NOTE_E4, NOTE_GS4, NOTE_GS4 NOTE_A4, NOTE_B4,
NOTE_A4, NOTE_A4, NOTE_A4, NOTE_E4,0, NOTE_CS4,0, NOTE_FS4,0, NOTE_FS4,0, NOTE_FS4, NOTE_E4, NOTE_E4, NOTE_FS4, NOTE_E4,
NOTE_D4, NOTE_D4, NOTE_D4, NOTE_CS4, NOTE_B3,0, NOTE_B3, NOTE_B3,0, NOTE_CS4, NOTE_CS4,0, NOTE_CS4,0, NOTE_A3,0, NOTE_A3,0, NOTE_F4,0, NOTE_F4,
NOTE_F4, NOTE_E4, NOTE_D4, NOTE_D4, NOTE_D4, NOTE_CS4,0, NOTE_B3,0, NOTE_B3,0, NOTE_B3, NOTE_B3,0,0, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4, NOTE_A4,
NOTE_A4, NOTE_G4,0, NOTE_FS4,0, NOTE_E4,0, NOTE_A4, NOTE_A4, NOTE_G4, NOTE_G4, NOTE_A4, NOTE_A4,
NOTE_E5, NOTE_FS5, NOTE_FS5, NOTE_E5, NOTE_A4, NOTE_A4, NOTE_E5, NOTE_E5, NOTE_FS5, NOTE_FS5, NOTE_E4, NOTE_F4
};
//note durations: 2 = half note, 4 = quarter note, 8 = eighth note, 12 = twelveth note, :
int noteDurations[] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
12, 8, 8, 8, 4, 8, 8, 8, 8, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 4, 2, 2, 2, 2, 2, 2,
12, 8, 4, 4, 2, 2, 2, 2, 2, 2, 12, 8,
};
void setup() {
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 12; thisNote++) {
// calculate the note duration as 1 second divided by note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / noteDurations[thisNote];
tone(12, melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(12);
}
}
void loop() {
// no need to repeat the melody.
}
This is the file included for pitches
/*************************************************
* Public Constants
*************************************************/
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#define NOTE_A1 55
#define NOTE_AS1 58
#define NOTE_B1 62
#define NOTE_C2 65
#define NOTE_CS2 69
#define NOTE_D2 73
#define NOTE_DS2 78
#define NOTE_E2 82
#define NOTE_F2 87
#define NOTE_FS2 93
#define NOTE_G2 98
#define NOTE_GS2 104
#define NOTE_A2 110
#define NOTE_AS2 117
#define NOTE_B2 123
#define NOTE_C3 131
#define NOTE_CS3 139
#define NOTE_D3 147
#define NOTE_DS3 156
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_FS3 185
#define NOTE_G3 196
#define NOTE_GS3 208
#define NOTE_AS3 233
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_CS4 277
#define NOTE_D4 294
#define NOTE_DS4 311
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_FS4 370
#define NOTE_G4 392
#define NOTE_GS4 415
#define NOTE_A4 440
#define NOTE_AS4 466
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_CS5 554
#define NOTE_D5 587
#define NOTE_DS5 622
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_FS5 740
#define NOTE_G5 784
#define NOTE_GS5 831
#define NOTE_A5 880
#define NOTE_AS5 932
#define NOTE_B5 988
#define NOTE_C6 1047
#define NOTE_CS6 1109
#define NOTE_D6 1175
#define NOTE_DS6 1245
#define NOTE_E6 1319
#define NOTE_F6 1397
#define NOTE_FS6 1480
#define NOTE_G6 1568
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 4978
As part of an engineering project for school we were asked to make a program that could play a simple song. We have created the code based on the example ToneMelody for the arduino program. we get an error after all of are notes are listed that highlights red on both are music_code file and our pitches.h file. However, on our pitches.h file the error stops at #define Note_AS3 233 it says exit status 1 expected declaration before '}' token. What does this error mean and how exactly can we fix it because the example tonemelody program works fine?
So, there's a number of errors in your posted sketch which would stop it from compiling.
NOTE_A3 is referenced but not defined
On the very first line of the definition of int melody[], there is no comma between NOTE_GS4 and NOTE_A4
On the third line of the definition of int noteDurations[], you are missing a comma between 8 at the end of the line, and the next element
If you correct all three of these, the code should compile just fine. You should, however, receive more than just one error like you describe from the Arduino IDE. I received notably more, which allowed me to at least figure out where each problem was. If you don't see it in the Arduino error box, you should at least see it through the command line output, which will allow you to track these down in the future.

Switch on/off NSLog with a boolean just like CCLog in cocos2d

I have a IS_TESTING boolean flag indicating whether the current build is testing
I want to hide NSLog if IS_TESTING is NO. And it should also support a single string parameter.
This is CCLog from cocos2d:
#define __CCLOGWITHFUNCTION(s, ...) \
NSLog(#"%s : %#",__FUNCTION__,[NSString stringWithFormat:(s), ##__VA_ARGS__])
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
This is what I write:
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if IS_TESTING == 0
#define CCLOG(...) do {} while (0)
#elif IS_TESTING == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#endif
use:
CCLOG(#"single string parameter");
CCLOG(#"string format %#", #"parameter");
It runs without crash, but nothing gets printed out.
EDIT:
#define IS_TESTING YES
I have tried
#if IS_TESTING == YES/NO, but still the same as 0/1, nothing gets printed out
Your code works perfectly. But IS_TESTING must be defined before you start the __CCLOG definition stuff.
So, in the .pch file, I wrote:
#define IS_TESTING 1
#define __CCLOG(s, ...) \
NSLog(#"%#",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if IS_TESTING == 0
#define CCLOG(...) do {} while (0)
#elif IS_TESTING == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#endif
And later:
CCLOG(#"%#", #"YES");
Since I have defined IS_TESTING to 1, we log. If I change it to 0, we don't.
As a bonus, I'll show you what I do. It's much simpler. Here it is:
#define MyLog if(0); else NSLog
This makes MyLog equivalent to NSLog. To turn off logging, change 0 to 1.

Resources