We distribute in Linux a static lib in both 64-bit and 32-bit versions. When troubleshooting a customer, I would like my diagnostic shell script to quickly eliminate the issue
oops, that missing sed means that it was displaying to many items.
Just in an answer:
count=$(nm foo.a | grep '^0' | head -1 | sed 's/ .*//' | wc -c)
((count == 17)) && echo 64bit
((count == 9)) && echo 32bit
((count == 0)) && echo '??bit'
How it's supposed to work:
In a 32 bit environment, you get addresses made up of 8 hex digits, adding the new line gives you 9
, In a 64bit environment, you get addresses made up of 16 hex digits, adding the new line gives you 17
.