# Using #define in C code

**URL:** <https://community.br-automation.com/t/using-define-in-c-code/8036>\
**Category:** Programming\
**Tags:** c-cpp\
**Created:** [August 21, 2025, 2:04am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036 "2025-08-21T02:04:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [August 21, 2025, 2:04am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036/1 "2025-08-21T02:04:12Z")

</div>

Hi,

I faced some issue using #define in C code. It was ok in C++ code. An example is below:

#define NO\_OF\_INPUTS 3

int connections[NO\_OF\_INPUTS];

I was not able to compile the code in a C file in B&R studio. Is this an existing issue?

Thanks and Regards,

Kenneth

---

<div class="post-metadata">

**Author:** ![christian.bauer](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christian.bauer/32/238_2.png) [@christian.bauer](https://community.br-automation.com/u/christian.bauer)\
**Post date:** [August 21, 2025, 5:53am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036/2 "2025-08-21T05:53:07Z")

</div>

Hi Kenneth,

if you are facing problems like that you should ALWAYS tell us what version and what IDE you are using.

E.g. there is NO “B&R studio”. We have “Automation Studio” or “Automation Studio Code”. Versions range from 2.x to 6.x with GCC versions up to 11.3.0 . What are you referring to?

Also from the snippet above we cannot determine WHERE in your code the statements are placed. Maybe they are located in the wrong position?

An example with Automation Studio 6.3.1.32 and gcc V11.3.0 compiles without any errors:

```java
#include <bur/plctypes.h>

#ifdef _DEFAULT_INCLUDES
   #include <AsDefault.h>
#endif

#define NO_OF_INPUTS 3
int connections[NO_OF_INPUTS];

void _CYCLIC ProgramCyclic(void)
{

}

```

---

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [August 21, 2025, 6:04am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036/3 "2025-08-21T06:04:09Z")

</div>

Hi Christian,

Thanks for your inputs. I am using Automation Studio 4.7.2.98. Could it be due to the Automation Studio version?

Regards,

Kenneth

---

<div class="post-metadata">

**Author:** ![christian.bauer](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christian.bauer/32/238_2.png) [@christian.bauer](https://community.br-automation.com/u/christian.bauer)\
**Post date:** [August 21, 2025, 6:24am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036/4 "2025-08-21T06:24:56Z")

</div>

This version is almost 6 years old.

To you have any specific needs for this version?

Older versions typically have problems with modern operating systems (e.g. Windows 11).

I would suggest Automation Studio 4.12 (if you have older hardware) or Version 6.3 (if you have up to date hardware).

---

<div class="post-metadata">

**Author:** ![christian.bauer](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christian.bauer/32/238_2.png) [@christian.bauer](https://community.br-automation.com/u/christian.bauer)\
**Post date:** [August 21, 2025, 7:00am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036/5 "2025-08-21T07:00:29Z")

</div>

Checked with 4.7.2.98 and gcc V4.1.2.

Works like a charm.

Do you mix C and C++ code?

`------------- Building project FourSevenProject, configuration Config1 -------------`  
`Analyzing project …`  
`Generating header files …`  
`Generating archive files …`  
`Compiling C:\Users\bauerc\Documents\AutomationStudio\47\FourSevenProject\Logical\Program\Cyclic.c …`  
`Compiling C:\BrAutomation\AS47\AS47\AS\GnuInst\V4.1.2\arm-elf\include\bur_bur_pvdef.c …`  
`Linking C:\Users\bauerc\Documents\AutomationStudio\47\FourSevenProject\Temp\Objects\Config1\X20CP0411\Program\a.out …`  
`Building program “Program” as “Program” …`  
`Build: 0 error(s), 0 warning(s)`

---

<div class="post-metadata">

**Author:** ![kenneth.tham](https://avatars.discourse-cdn.com/v4/letter/k/FF8800/32.png) [@kenneth.tham](https://community.br-automation.com/u/kenneth.tham)\
**Post date:** [August 22, 2025, 2:01am UTC](https://community.br-automation.com/t/using-define-in-c-code/8036/6 "2025-08-22T02:01:24Z")

</div>

Hi Christian,

Apologies for the confusion. The error was due to a stray semi-colon in my #define statement. (eg. #define NO\_OF\_INPUTS 3;) It is working now after removing the semicolon at the end.

Regards,

Kenneth
