# Midnight C

{% hint style="danger" %}
Midnight C is for the older VEX Cortex which is no longer supported
{% endhint %}

**Features -**

* **Not VEX-Supported**
* Native code compilation
* 32- and 64-bit types
* Partial multitasking
* Uses [Eclipse](https://www.eclipse.org/) IDE
* Interrupt control
* Pointer and [register](/software/general/register-programming.md) control
* Purdue Robotics OS

The **Midnight C** platform, often referred to in the past as the **"Makefile"**, is a cross-platform method of compiling native C code for the [VEX Cortex](/vex-electronics/legacy/vex-cortex.md). It supplanted [Robotc](/software/vex-programming-software/robotc.md) during VEX Gateway as the primary language for programming the Cortex. Initial versions used the EasyC runtime library to interface with VEX parts, making it fully [EasyC](/software/vex-programming-software/easyc.md) compatible; the development of the Purdue Robotics OS brought a more powerful API compatible with a variety of existing environments.

## Installation

Midnight C is compatible with Windows, Mac OS X, and Linux.

Firmware (Mastercode) reflashing for Midnight C is performed using the same procedure as reflashing EasyC firmware.

## Features

* Uses the GNU GCC compiler for ARM
* Can use any standard C syntax, library, data type, or function
* Powerful, high-speed library implementation surpasses I/O and interrupt performance of even the EasyC library
* Low-level access available to system registers, allowing the implementation of protocols such as [SPI](/electronics/general/spi.md) or [I2C](/electronics/general/i2c.md)
* Midnight-C IDE (based on the Eclipse IDE) handles routine compilation and upload tasks
* Vast improvements in size and speed

## Shortcomings

* Initial setup still needs work
* Not supported by VEX

## Object-oriented programming

**C++** support is also available; if a file is created with a .cpp extension, it will be compiled using arm-none-eabi-g++. The code used must have entry points from one of the built-in C files through a C++ function exposed via extern 'C' { ... }. Otherwise, any standard C++ construct or syntax can be used; the API header files have the appropriate declarations for use of the standard C functions. ***Beware of code size*** - while using C++ itself imposes only a small penalty, any function in the C++ standard library (e.g. new, std::) will often add *50-100 KB* to the hex file.

Please note that object-oriented principles tend to encourage practices such as dynamic memory allocation and excessive indirection which may conflict with the embedded system goals of speed and program size. When possible, use C code.

### Teams Contributed to this Article:

* [BLRS](https://purduesigbots.com/) (Purdue SIGBots)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.purduesigbots.com/software/vex-programming-software/midnight-c.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
