From f48456686d0bf961d5875d6c128c86e63443991d Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" Build tags #File Suffixes are typically a nicer approach if they cover what you need.
For the sake of demonstration, let’s take POSIX: You could use foobar_unix.odin
, which has no special meaning to the compiler at all, and use a tag in the file itself.
Here’s an example of a file that will only be included on Linux or Darwin:
-//+build linux, darwin
+#+build linux, darwin
+package foobar
+
The opposite, excluding the file on both Linux and Darwin, is achieved like this:
+#+build !linux
+#+build !darwin
package foobar
Implicit context system #
In each scope, there is an implicit value named context
. This context
variable is local to each scope and is implicitly passed by pointer to any procedure call in that scope (if the procedure has the Odin calling convention).
@@ -2869,10 +2873,10 @@ @(private)
@(private="file")
my_variable: int // cannot be accessed outside this file
@(private)
is equivalent to @(private="package")
.
Using //+private
in a file at the package declaration will automatically add @(private)
to everything in the file
//+private
+Using #+private
before the package declaration will automatically add @(private)
to everything in that file:
+#+private
package foo
-
And //+private file
will be equivalent to automatically adding @(private="file")
to each declaration. This means that to remove the private-to-file association, you must apply a private-to-package attribute @(private)
to the declaration.
+
And #+private file
will be equivalent to automatically adding @(private="file")
to each declaration. This means that to remove the private-to-file association, you must apply a private-to-package attribute @(private)
to the declaration.
@(require)
#Requires that the declaration is added to the final compilation and not optimized out.