Forums

Compiler directives

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Compiler directives

Postby Charles » 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.
@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
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: Compiler directives

Postby arisawa » Thu Aug 20, 2009 2:04 am

@args directive is I seem to be "-ert:yes" option is not available.
is it a specification?
I test case:
@args -c -ert:yes -turbo -ref:System.Drawing
arisawa
 
Posts: 51

Re: Compiler directives

Postby Charles » Thu Aug 20, 2009 4:46 am

Not sure. Maybe -ert: gets implemented too early for @args to have an effect. I can't look at right at this moment.

For now, you will have to pass -ert:yes on the command line.
Charles
 
Posts: 2510
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron