---
title: "Slice files"
description: "Understand how Slice definitions are organized in Slice files."
url: https://docs.icerpc.dev/slice/basics/slice-files
docs_index: https://docs.icerpc.dev/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.icerpc.dev/llms.txt).

# Slice files

Understand how Slice definitions are organized in Slice files.

## File extension

Slice definitions must be stored in files with the `.slice` extension, known as Slice files. The Slice compiler ignores files with other extensions.

## Source files and reference files

The Slice compiler accepts two categories of Slice files: source files and reference files. The compiler parses all these files but only generates code for the source files.

Like C# and unlike C and C++, the Slice compiler considers the definitions in all its input files and does not impose any ordering requirement. For instance, you can use a type before defining it:

```slice
module Example

interface WidgetFactory {
    // We can use Widget before defining it.
    createWidget(name: string) -> Widget
}

struct Widget {
    name: string
    color: Color
}

enum Color { Blue, Red, White, Yellow }
```

Two files can also contain definitions with circular references, such as:

```slice
// in Chicken.slice
module Coop

struct Chicken {
    name: string
}

interface Henhouse {
    hatch(egg: Egg) -> Chicken
}
```

```slice
// in Egg.slice
module Coop

struct Egg {
    weight: float64
}

interface Nest {
    lay(chicken: Chicken) -> Egg
}
```

## Preprocessing

The Slice language provides a few basic preprocessing directives for conditional compilation. For example:

```slice
module VisitorCenter

interface Greeter {
    greet(name: string) -> string

#if NEXT_GEN // only available in the NEXT_GEN version of Greeter
    sing(songName: string) -> Sequence<uint8>
#endif
}
```

Slice does not provide a preprocessing directive to include or import a Slice file into another Slice file.
