Wiki
Version 4 (modified by hopscc, 5 years ago)

--

Cobra Compiler Directives

Compiler directives are options, instructions or hints provided to compiler
from within code files. These may be items also provided as commandline args.

The various cobra Compiler directives are

@args
@ref
@help
@number
@platform
@error
@warning
@throw <---for internal use by cobra..

@args
Specifies the provision of a (cobra compiler commandline) arg.
The option follows the @args as if given on the compiler commandline.

e.g.

@args -t:winexe

specify a compiler option giving a commandline arg that indicates that the current assembly should be compiled as a Windows Executable

@args -lib:'C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0'

specifies a search directory for the cobra compiler to look in to find any referenced assemblies.

@ref

Indicates explicitly an assembly filename for the resolution of (used) references.

e.g.

@ref "PresentationFramework"

specifies referencing "PresentationFramework?" assembly from GAC which

could otherwise have been given as -ref:"PresentationFramework" on the commandline

@ref 'c:\somedirectory\validAssembly.exe'
@ref 'c:\somedirectory\validAssembly.dll'

specifies referencing assemblies by giving absolute paths to both .exe and .dll files

@help
Directive to generate an HTML help file for a given expression, statement or declaration.
The output file is intended to give the developer:

  • information about the topic in general
  • interfaces to types
  • a link to the Cobra wiki where appropriate
  • a link to the specific type's documentation on the web, where determinable
  • ready-made search links

See  http://cobra-language.com/forums/viewtopic.php?f=4&t=810&p=4195#p4125

@number

Set the actual numeric type for any uses of both the 'Number' type and the default numeric type for any fractional literals (such as '1.0').

This usually defaults to Decimal. ( see CommandLine option 'Number')

See http://cobra-language.com/trac/cobra/wiki/Troubleshooting

@platform
Directive to specify that this source is specifically intended (only) for a specific platform. Presumably the code uses libraries or API's only available on that platform. If the platform directive and the compiler option backend settings are not compatible compilation will be aborted.

Values may be one of :

  • any - default - build on any platform (explicitly)
  • portable - (future) build for a 'portable' platform
  • clr - build for a CLR platform ( .Net - Windows and mono)
  • jvm - build for a jvm platform
  • objc - (future) build for an objective-C platform

e.g.

@platform jvm
# build only on/for jvm platform 

@platform any
# same as default

Additional (or different) platforms may be supported (or completed) in the future.