# Cog's presence detection

We will use my [ObjectTags ](https://app.gitbook.com/s/jP5XAKMs1xUM2psZ0ZK9/)plugin as an example.

Inside of the `build.cs` file, you'll find this code:

<figure><img src="https://4281265215-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMyo485jJ75PBKbKwjZt%2Fuploads%2FjMOCHyLDNK6CPcfjutbH%2Fimage.png?alt=media&#x26;token=d4dff862-5d03-4841-912e-83659d64a9a3" alt=""><figcaption></figcaption></figure>

This code will enable or disable the `COG_INSTALLED` preprocessor macro depending of the `Cog` plugin can be found inside the `Plugins` folder and add it as a dependency if it's found.

This setup enables us to write Cog dependend code, which is disabled and ignored by the IDE and compiler if the Cog plugin is disabled.

<figure><img src="https://4281265215-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMyo485jJ75PBKbKwjZt%2Fuploads%2FkohLJ9LUCZxIUbsvCBkS%2Fimage.png?alt=media&#x26;token=9820396d-67c3-4c14-9874-f4d3ab2a7315" alt=""><figcaption></figcaption></figure>

In the code example above, if Cog is missing, the code will automatically be disabled and not recognized by the IDE. Thus, not causing any errors and allowing you to continue using the plugin.

{% hint style="warning" %}
It's important you do `COG_INSTALLED` first.

The compiler is smart enough that if it sees `COG_INSTALLED` as false, it won't bother to check `ENABLE_COG`, which in the case of Cog not being installed, would result in an error. But since `COG_INSTALLED` returns false before `ENABLE_COG`, the compiler immediately strips it out and doesn't bother checking it.

If the checks are reversed, you'll get an error saying `ENABLE_COG` is undefined if Cog is ever uninstalled.
{% endhint %}

In some cases, you might have to wrap `#include`'s with the `#if COG_INSTALLED` preprocessor macro, then use `#if ENABLE_COG`.

<figure><img src="https://4281265215-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHMyo485jJ75PBKbKwjZt%2Fuploads%2FeOZGFCILGeNucQJ8I1cO%2Fimage.png?alt=media&#x26;token=1edf04b6-6ddf-4109-8f80-b78b987e3138" alt=""><figcaption></figcaption></figure>
