Something I always forget and have to look up.
1) Print predefined macros:
gcc -dM -E - </dev/null | sort | less
2) Print predefined macros and macros introduced by a specific header
echo “#include <stdlib.h>” > foo.h
gcc -dM -E foo.h | sort | less
Reference for -dM is in the cpp man page.
I upgraded my desktop machine to Gutsy today to have a play with it before upgrading my laptop. I’m really glad I did it in this order as it appears there may be a regression in the version of Java 6 shipping on Gutsy.
I happened to test out a Java game which uses Full Screen Exclusive Mode with a DisplayMode of 800×600. So far this app has been working ok on Feisty but when I tested it today on Gutsy it couldn’t change display mode. I discovered that Java was only able to see the current screen mode of 1280×1024 and no others.
I’ve opened a bug on Launchpad here: #154613: Java cannot change display modes / screen resolution in Gutsy, and I’ve been digging in trying to work out what’s going wrong.
I managed to locate the JNI function call in Java’s native C source code where it gets the list of modes. It’s called Java_sun_awt_X11GraphicsDevice_enumDisplayModes(...) and is in the file j2se/src/solaris/native/sun/awt/awt_GraphicsEnv.c. As expected the Ubuntu packages are built from the Sun Linux binaries - no source code. I couldn’t find the Java 6 source on Sun’s site, the link appears to be wrong. Instead I found the file in the Icedtea/OpenJDK source tree. Icedtea on Gutsy has the same problem so I’m fairly happy this is the the same or roughly the same code as in Java 6.
The function makes use of the XRandr Xorg extension to query the available display modes. I coded up a small test to see if XRandr was behaving correctly. It is, on both Gutsy and Feisty. So it looks like it could be something in Java 6 u3.
Will keep digging, as I really need this to work.
This year I’ve been making a concerted effort to learn C. Properly.
I’ve toyed with it a good few times over the last few years, but never studied it in a focused way. After the Chairman of our company (actually a real C programmer) indicated that I was “a bit of a girl’s blouse” because I didn’t know C, I decided something had to be done.
My ultimate goals are to be able to create or improve Linux drivers for bits of hardware that don’t work, and to be able to fix bugs for myself in C based Linux apps.
A games programmer I know recommended that the K&R book was still the best in his opinion, so I bought a copy and got started. Others have told me it’s not so good. I can understand this point of view, if I didn’t already know other programming langs it would be quite an uphill climb, but I’m really enjoying it.
Another decent book I’m planning on reading properly once K&R is done is Expert C Programming by Peter van der Linden (Paul: thanks for recommending I read this). If anyone knows any other books or great sources of C info/wisdom I’d love to hear about them.
I remember looking at C programming.com years ago and it was quite useful then. But it looks like it’s got loads of really great material on it now.