# Code syntax



## Phishfry (Jul 22, 2016)

Simple code question.
Pound sign on .conf files comments out line so it is not used.
Why is pound sign used for device driver code?
For example:
#include <sys/module.h>

Is this just annotating a header?


----------



## Murph (Jul 22, 2016)

Just different syntax for different languages.  C syntax of `#thing` is a compiler / preprocessor "directive".

There's no generic .conf syntax, but the special case of /etc/rc.conf, /etc/periodic.conf, and some other similar BSD files comes from sh(1), as they are really just shell scripts which are "sourced" into other shell scripts.  It would be bad practice to actually treat them as generic shell scripts, and they should be restricted to the narrow subset of shell syntax described by rc.conf(5), etc.  Theoretically, something else on the system could interpret them in the narrow context of just setting variables (perhaps not actually using the shell to parse them).


----------



## Phishfry (Jul 22, 2016)

I am attempting to hack together a GPIO driver for SMSC SCH3114 LPC-IO device  on an Advatech SBC. Alot of their boards use the SCH3114.

There are no i386 or AMD64 gpio input-output drivers in the source tree. Only Arm, Mips and PowerPC


----------



## Phishfry (Jul 22, 2016)

Why does an .m file use both conventions. A pound to include and a pound to comment out line?
https://github.com/freebsd/freebsd-base-graphics/blob/master/sys/dev/gpio/gpiobus_if.m


----------



## Phishfry (Jul 22, 2016)

Nevermind I get it. A pound<command> is different than a pound <random comment>


----------



## Phishfry (Jul 22, 2016)

Gonzo has a good example for me to follow with his Soekris work.


----------



## SirDice (Jul 22, 2016)

Phishfry said:


> Pound sign on .conf files comments out line so it is not used.


Not everywhere. In ~/.vimrc for example it's a single quote:

```
' this is a remark
set ts=2
```
Different languages can have different syntax. But most of the time it's common to use a hash.



Phishfry said:


> Nevermind I get it. A pound<command> is different than a pound <random comment>


Yeah, it's confusing though, I have to agree. It can lead to interesting bugs too:

```
#some text
#include code to fix bug
#some more text
```
This actually produces an error. This doesn't:

```
# some text
# include code to fix bug
# some more text
```
I have found and fixed "bugs" like that


----------



## Murph (Jul 22, 2016)

Ugh, yeah, that style/syntax.  It's a somewhat unholy collision of C, Objective-C, and non-C syntax. It does work though, so just have to be careful with the exact syntax on comments.


----------

