Wednesday, December 03, 2014

printf and size_t from clang using %zu

C99 added the printf format specifiers %zu, %zx, etc. for printing something of the type size_t.

This worked fine on my Macintosh last night running Mac OS X 10.10 (Yosemite).

However, on my Windows machine at work using clang 3.6.0, it just printed zu or zx. That is, until I realized that I needed to add -std=c99 to my command line. Then, it recognized %zu and %zx correctly.

Tuesday, July 22, 2014

Python for .NET "import" fails

If you're using Python for .NET, and you have the following Python code:
import clr
import MyNETNamespace
and you get the error message:
ImportError: No module named MyNETNamespace
You should try two things:
  1. Make sure your .dll is named "MyNETNamespace.dll"
  2. Make sure all the .dll's that MyNETNamespace.dll is dependent on are in the directory, too. 

Sunday, February 16, 2014

A quote about design

Designers notice the gap between functional and delightful, and that’s why we obsess over the little details.

Source: http://www.gv.com/lib/design-details
 That's how I feel about software APIs.

Saturday, January 11, 2014

Clang can't find stdio.h, etc

I decided to play with Clang on Windows this morning, using the pre-compiled binaries. However, when I try to compile a hello world app, I get this error message:

fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.


Googling didn't help me figure out where to get the standard library for c. But, when I did clang --verbose hello.c, I got a hint:

...
ignoring nonexistent directory "c:/mingw/include"

...

So, I installed MinGW (and its mingw32-base and mingw32-gcc-g++ packages).  Now, I have that directory, and have a standard library for C that Clang can use, along with a ton of useful utilities.  I then added the C:\MinGW\bin directory to my path.




Thursday, August 01, 2013

Excel won't open files when I double-click them

My Excel, for some reason, decided that when I double-clicked a spreadsheet file, it would launch but wouldn't actually open the file. This has happened to me before, and I found a page somewhere on the net that told me how to fix it. I couldn't find that page, but I did figure out how to fix it, so I'm posting the solution here.
  1. Go into Excel Options
  2. Select Advanced
  3. Scroll down to the General subheading
  4. Uncheck the box next to Ignore other applications that use Dynamic Data Exchange (DDE)

Wednesday, July 31, 2013

Beyond Compare with Mercurial

To get the excellent Beyond Compare to work as my graphical diff tool in Mercurial (Hg) on Windows, I needed to add the following lines to my mercurial.ini:
[extdiff]
cmd.bcomp = C:\Program Files\Beyond Compare 3\BComp.exe
opts.bcomp = /ro /solo
Then, from the commandline, I can use
hg bcomp
to get a diff of all changes in the directory, or I can specify a filename to see differences in it. Without the /ro /solo, I ran into issues with the temporary directories in a dir diff being deleted immediately before Beyond Compare got a chance to compare them. That's because without them, Hg thinks that Beyond Compare completed immediately. Those options tell Beyond Compare to hold off on telling Hg it's done until after you have manually closed Beyond Compare.

Monday, July 22, 2013

Beaglebone Flash Image on Linux

The BeagleBoard website assumes you're using Windows in all of its instructions. I am running Linux Mint and wanted to update the OS image on my SD Card.

My ThinkPad has a built-in SD card reader. I didn't know what Linux called it, but I did see SD cards I put in show up in my file browser. Turns out you can list your disk drives with the command:

sudo fdisk -l
I got output like this:
Disk /dev/mmcblk0: 3904 MB, 3904897024 bytes
255 heads, 63 sectors/track, 474 cylinders, total 7626752 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *          63      144584       72261    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          144585     7132859     3494137+  83  Linux
Then, I used this command to "burn" the image to the card:
sudo dd if=./Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.06.20.img of=/dev/mmcblk0
You might want to stick a "time" on the front of that command: it's going to take a while (a little more than half an hour for me). You can check on its progress by using ps -a to get the pid of dd, then send it a USR1 signal with sudo kill -USR1 pid. That will cause it to print status information to stdout.