The "underscore" package can help you when you have a lot of underscores to escape in your text, but you have to be careful with file names, cite or ref tags :

The skips and penalties ruin any kerning with the underscore character
(when a character is used). However, there doesn’t seem to be much, if
any, such kerning in the EC fonts, and there is never any kerning with
a rule. You must avoid “_” in file names and in cite or ref tags, or
you must use the babel package, with its active-character controls, or
you must give the [strings] option, which attempts to redefine several
commands (and may not work perfectly). Even without the [strings]
option or babel, you can use occasional underscores like:
“\include{file\string_name}”.

It still does not work for me. I've tried "\lstinputlisting{abcd/test_file.c}" as a minimum command, with or without escaping the underscore, and I still get the same error. Could it have something to do with the encoding packages I use? ([utf8x]{inputenc}, [french]{babel})
–
BenCNov 17 '11 at 17:46