> For the complete documentation index, see [llms.txt](https://docs.intrepidcs.com/vspy-3-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.intrepidcs.com/vspy-3-documentation/3.9.15/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/working-with-the-c-code-interface.md).

# Working with the C Code Interface

### Example Videos

Please review the example videos for an overview on how to use the C Code Interface.

### Adding a New Project

To add a new project, click on the "Add Project..." button (Figure 1), and a drop down will appear giving the options to add a new project, [convert from CAPL](/vspy-3-documentation/3.9.15/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/c-code-interface-capl-conversion.md), or add an existing project.

![Figure 1: Adding a new C Code project in the C Code Interface view.](https://2396693198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlRJv2XDCMeZSU0VbeZlG%2Fuploads%2Fgit-blob-c4b62522f007b4b13319274331a411435e244b06%2Fadding_project.gif?alt=media)

If a new project is selected, a windows will pop up called "Add New C Code Project". Here a project name and a description is entered in. Vehicle Spy will then create a new base project and launch Visual Studio. Next the "Edit" button can be used to create events or the project can be worked with in Visual Studio. Make sure you build the DLL once before starting Vehicle Spy, otherwise, you will not have anything for Vehicle Spy to load - this will result in an error.

![Figure 2: You need a project name and description to create a new project.](https://2396693198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlRJv2XDCMeZSU0VbeZlG%2Fuploads%2Fgit-blob-e286053586c61fe50d8c50c4018f2683f609a669%2Fadd_new_project.gif?alt=media)

### Editing a Project

After a new project is created, events can created by clicking the "Edit" button in the C Code Interface. In the setup dialog you can add event functions and change the name and description of the project. For setup of the event functions please see the sections for [message](/vspy-3-documentation/3.9.15/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/c-code-interface-functions-and-events/functions-and-events-message-objects.md), [application signal](/vspy-3-documentation/3.9.15/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/c-code-interface-functions-and-events/functions-and-events-application-signals.md), and [timer](/vspy-3-documentation/3.9.15/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/c-code-interface-functions-and-events/functions-and-events-timers.md) events. If you create event functions, make sure to manually copy the event handler code to your SpyCCode.c file. This will help you avoid a linker error when building your project.

![Figure 3: The edit button will allow you to edit your C code project including adding event functions.](https://2396693198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlRJv2XDCMeZSU0VbeZlG%2Fuploads%2Fgit-blob-a11ce42ed9c99e6d58e261e98dd6a02abc5cdf92%2Fedit_C_code_project.gif?alt=media)

### Your Work Goes Here: SpyCCode.c

The most important file in the Visual Studio project is the SpyCCode.c file. This file is where the C code you write is placed. In this file, you can implement all the event functions and the Spy\_Main() function. This file includes "vspy.h", which defines all the messages in your Vehicle Spy project. See the screen shot below.\
\
*Note*: Advanced users can separate their project into as many C files as they would like. This is recommended for very large projects. The SpyCCode.c file is the default C file and works well for small projects and beginners. So, if you know what you're doing in Visual Studio and want to have a separate C file for every event for better organization - go for it! In the end its all just C.

![Figure 4: The SpyCCode.C implementation file.](https://2396693198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlRJv2XDCMeZSU0VbeZlG%2Fuploads%2Fgit-blob-f3705ffccb94ce74b2d9e27535ebef7d2725ff0b%2Fspyccode.gif?alt=media)

### Automatically Generated Files: vspy.c and vspy.h

Vehicle Spy automatically generates two files from your current Vehicle Spy setup. These include a header file (vspy.h) and an implementation file (vspy.c). These files can become inaccurate as you make changes to your Vehicle Spy setup. So, you will need to regenerate these as necessary during your development. You can do this by clicking on the "Update Support Files" button in the C Code Interface view in Vehicle Spy. These files will also be automatically updated every time you edit the C code project within Vehicle Spy.

![Figure 5: Clicking Update Support Files will update the vspy.c and vspy.h files.](https://2396693198-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlRJv2XDCMeZSU0VbeZlG%2Fuploads%2Fgit-blob-86ac9d3c4cc5493f521a0139c3c320344c56e1cf%2Fupdate_support_files.gif?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.intrepidcs.com/vspy-3-documentation/3.9.15/vehicle-spy-main-menus/main-menu-scripting-and-automation/c-code-interface/working-with-the-c-code-interface.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
