Compiler directives
Posted: Mon Apr 06, 2009 7:08 pm
As previously mentioned, the syntax for compiler directives is now changed to "@foo" instead of "%% foo". The problem with the %% approach is that in all other cases, doubling up an arithmetic operator implies another arithmetic operation. In Cobra this includes // (integer division) and ** (power to). Other languages also have -- and ++. So I feel that %% was bad choice (originally made by me).
The old %% syntax is still supported so your programs will not break. And although I have updated the samples, how-to's and tests, I have not yet added a warning for using %%. I'll likely add that warning a month from now. I prefer that these transitions are gentle on you, the user.
Also, a new @ref directive has been added which is described below.
The most popular directives are:
@number float|float64|float32|decimal
Sets the actual type of the "number" alias type.
@ref <path>
Adds a binary library reference (typically .dll). You can do this on the command line, but specifying it in a source file means you don't have to remember to do so.
Example from the WFP How To:
You can include the .dll extension, but it is unnecessary. You can use single or double quotes. You can leave the quotes out if the name is a simple identifier like Foo. You do not need to specify the path if the DLL is in the GAC or your local directory.
@args <args>
Enables command line arguments to be specified inside a file. This is quite powerful as there are a variety of command line args which you can learn about with "cobra -h"
The old %% syntax is still supported so your programs will not break. And although I have updated the samples, how-to's and tests, I have not yet added a warning for using %%. I'll likely add that warning a month from now. I prefer that these transitions are gentle on you, the user.
Also, a new @ref directive has been added which is described below.
The most popular directives are:
@number float|float64|float32|decimal
Sets the actual type of the "number" alias type.
@number float64
@ref <path>
Adds a binary library reference (typically .dll). You can do this on the command line, but specifying it in a source file means you don't have to remember to do so.
Example from the WFP How To:
@ref 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework'
@ref 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore'
@ref 'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase'
You can include the .dll extension, but it is unnecessary. You can use single or double quotes. You can leave the quotes out if the name is a simple identifier like Foo. You do not need to specify the path if the DLL is in the GAC or your local directory.
@args <args>
Enables command line arguments to be specified inside a file. This is quite powerful as there are a variety of command line args which you can learn about with "cobra -h"
@args -v -debug -out:myprog.exe