Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Sometimes I find in the source code files comments have quotation marks like these ,notice the ` :

`help'
``help"

For example, these are comments from GNU cat source code file, cat.c:

  /* Plain cat.  Copies the file behind `input_desc' to STDOUT_FILENO.  */

>

  /* Select which version of `cat' to use. If any options (more than -u,
     --version, or --help) were specified, use `cat', otherwise use
     `simple_cat'.  */

>

/* Suppress `used before initialized' warning.  */

While in other parts, "" is used :

  /* Determines how many consecutive newlines there have been in the
     input.  0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1,
     etc.  Initially 0 to indicate that we are at the beginning of a
     new line.  The "state" of the procedure is determined by
     NEWLINES.  */

What does ` mean? and what is it used for?

share|improve this question
    
I would say that you should treat single vs double quotes like Python interpreter does - does not matter, unless you have a single quote inside double quotes or the other way around. When I need to use quotes, I like using double quotes because they are more visible. I do not always need to use quotes. I might denote a named parameter with something like <ConfigFilePath>. I would use quotes in documentation if spaces were important, but I would try to make it human readable: Type "Green " without quotes and tab off in order ... in other cases quotes aren't the best choice. There is no standard –  Job Feb 8 '12 at 23:16
1  
add comment

3 Answers

up vote 3 down vote accepted

It's the result (habit) of someone using LaTeX - it doesn't mean anything.

E.g., in LaTeX, ``hello there'' would result in "hello there".

If, however, you see as part of a shell script, the command within the backticks () is performed. E.g.,

$ echo `whoami`
awesome-linux-accountname
share|improve this answer
add comment

In general, there is no standard meaning for quotes in comments. Some standard meaning may be defined within an organization, or for a particular project, but I've never seen that done.

In your examples, the quotes are sometimes used to indicate that the enclosed word is the name of something, like a variable ('input_desc'), or a program ('cat'). There may be conventions defined for GNU source code, but it's not clear from the examples that there are.

In the last example, it is not clear to me why "state" was quoted.

share|improve this answer
add comment

In the olden days, the glyphs displayed for ` and '  produced nicely-symmetric "smart quotes" rather than the Unicode-correct unbalanced mess we see today.

Code and habits from that time use them as single smart quotes, and repeat them as a simulacrum of double smart quotes:

``help''

but this is no longer recommended for the GNU code that it arguably originated in.

There is futher reading and background in Markus Kuhn's treatise here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.