Yumbrad logo

7.21.05

GCC likes to break your code

Filed under: — Bradley @ 6:34 pm

I was trying to write a macro that, based on the endianness of the target machine, would either index an array, or directly access a struct field…

#if __BYTE_ORDER == __BIG_ENDIAN
#define GET(x, fieldname) ((struct x*)x)->##fieldname
#else
#define GET(x, fieldnum) setfield(x, fields[fieldnum]);
#endif

This used to work, but apparently GCC 3.x breaks this - I got errors like ‘pasting “->” and “field” does not give a valid preprocessing token.’ There were a lot of results on google when searching for “does not give a valid preprocessing token”… I eventually downloaded somebody’s gzipped patch, which inside just replaced ## with /**/ … simple, eh? So I thought I’d put this up so its out there with a simple, non-gzipped explanation of how to get around the issue of ## not working for pasting anymore.

3.17.05

Motherboard

Filed under: — Bradley @ 1:20 pm

Ok, I was seeing instability to various degrees with my self-built computer - sometimes it would crash once a month, sometimes once a week, sometimes once a day… I thought it was a USB camera I had, I thought it might be the power supply, I thought it could be that I damaged the ram slot. I think I’ve finally figured it out though, from an esoteric trail of google searches (one of them was ‘memtest86 “test 5″ cas 2-3-3-6 geil’, one was ‘ga-7n400 set cas’)… I wanted to document the solution here, with plenty of keywords, in case anyone else runs into this problem.

The things I learned:

  • A memtest86 bootable CD is great for testing your memory settings. And it’s freeware! Hit ‘c 1 3 5 [enter] 0′ to loop on the test that catches the most problems.
  • NForce2 chipsets are reportedly unstable with a T(RAS) of lower than 11
  • Many people have problems with a CAS of 2, even if their memory supposedly supports it. Many suggestions to put it at 2.5
  • A few suggestions to bump the DIMM voltage up to +0.1
  • In order to change all these settings on most Gigabyte motherboards, you must hit control-f1 at the main CMOS setup screen!

I have a GA-7n400 pro2 motherboard, and Geil ram that is supposedly rated 2-3-3-6. With things at default (no overclocking or anything), I would get a few errors every so often looping on test 5 (which == a few crashes every so often in windows). After using many combined suggestions around the web, I changed my settings in CMOS to 2.5-3-3-11, and bumped the DIMM voltage by +0.1. Now, 24 passes in memtest86 test 5 and no errors! Beeeautiful. (some more keywords: lockup, unstable, nforce)

Powered by WordPress