# C Code Interface: Object Names, Debugging, and Common Mistakes

### The Importance of an Object Name in a C Code Project

After your project is built you can run it over and over. The project from that point, just like C, references every object in Vehicle Spy by name. So, if you change the name or delete an object in your Vehicle Spy setup that you use in a C project you will need to open Visual Studio and rebuild the project. This also means the C code projects can be reused across Vehicle Spy setups if you manage to keep the names the same for the objects you use.

![Figure 1: Vehicle Spy attempts to find the objects you used in Vehicle Spy using object names but if it cannot you will get an error.](https://3170208387-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL6lcovCpkhoS9uTOFtEp%2Fuploads%2FA8aFc5tFo82lZZoofGxp%2Fname_lookup_error.png?alt=media\&token=23bf6640-69a7-4990-86c0-684bcd629998)

### Debugging Your C Code

Visual Studio supports debugging two ways. First, is it will launch Vehicle Spy every time you press run. Another allows you to connect to a running copy of Vehicle Spy (called attach to process) Vehicle Spy will allow you to build and connect to it when Vehicle Spy is not online. Therefore, the most productive way is attaching to an existing Vehicle Spy. Only Visual Studio standard edition or better supports attaching to an existing Vehicle Spy.\
\
You cannot build your project when Vehicle Spy has the C code loaded. Therefore, you must go offline in Vehicle Spy in order to fully build your project.

![Figure 2: Attach to process allows you to connect to an already running copy of Vehicle Spy for debugging.](https://3170208387-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL6lcovCpkhoS9uTOFtEp%2Fuploads%2FUFwEHXvwZ0TH0RfAboHH%2Fattach_to_process.gif?alt=media\&token=c2861d82-a1e0-4969-b3da-a089884bf970)

![Figure 3: Step 2 of attach to process - select vspy3.exe - make sure Vehicle Spy is offline!](https://3170208387-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL6lcovCpkhoS9uTOFtEp%2Fuploads%2FgGH0L3WP5lUuhjiF3MMX%2Fattach_to_process2.gif?alt=media\&token=bb6ea5d0-e05c-4d70-861a-8166a8a30193)

![Figure 4: The Visual Studio debugger in operation.](https://3170208387-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL6lcovCpkhoS9uTOFtEp%2Fuploads%2Fq7Q84N9AFpsyUGDk4JJI%2Fdebugger.png?alt=media\&token=b2c130dd-7c7a-455d-9278-a7e63b867fed)

### Common Mistakes for Building your project

1\) You created an event function, but did not implement it in SpyCCode.c. This causes a linker error. Make sure to copy the C function from the Event Code tab in the edit dialog for the C code module.

![Figure 5: A linker error will occur if you setup an event but don't implement the function in SpyCCode.C.](https://3170208387-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL6lcovCpkhoS9uTOFtEp%2Fuploads%2FBqY72YceTgHQK4XDeY8H%2Ftroubleshooting_linkererror.gif?alt=media\&token=ba5d6cd9-b18f-4ec6-b289-91dee0f75f38)

2\) You try to build the project while Vehicle Spy is online. The project is loaded. Go Offline in Vehicle Spy and then build the project.

![Figure 6: A linker error will occur if you build and Vehicle Spy is online.](https://3170208387-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FL6lcovCpkhoS9uTOFtEp%2Fuploads%2FFGb9qvT4xbpHzWX3PCoq%2Ftroubleshooting_loaded.gif?alt=media\&token=b5510ee7-6fd0-4990-9c1d-eb489d9cf80a)
