# a function-definition is not allowed here before '{' token

**URL:** <https://forum.arduino.cc/t/a-function-definition-is-not-allowed-here-before-token/648207>\
**Category:** Programming\
**Created:** [April 12, 2020, 9:52am UTC](https://forum.arduino.cc/t/a-function-definition-is-not-allowed-here-before-token/648207 "2020-04-12T09:52:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fahadqht](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@fahadqht](https://forum.arduino.cc/u/fahadqht)\
**Post date:** [April 12, 2020, 9:52am UTC](https://forum.arduino.cc/t/a-function-definition-is-not-allowed-here-before-token/648207/1 "2020-04-12T09:52:01Z")

</div>

i have issues compiling the code for my project it will shows (a function-definition is not allowed here before '{' token

i try to change and set the code many times,however, i could not finish sketching the code. could someone help me.

 ![Capture.PNG](https://europe1.discourse-cdn.com/arduino/original/3X/c/b/cbb377c714c5ca4a1cae117deb32778566efcba8.png)

[finalcode.ino](https://forum.arduino.cc/uploads/short-url/b86fwDYtK4FrYRdWLom0HMTFKWy.ino) (6.17 KB)

---

<div class="post-metadata">

**Author:** ![slipstick](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@slipstick](https://forum.arduino.cc/u/slipstick)\
**Post date:** [April 12, 2020, 10:11am UTC](https://forum.arduino.cc/t/a-function-definition-is-not-allowed-here-before-token/648207/2 "2020-04-12T10:11:29Z")

</div>

You are missing a } to close setup() and another at the end of loop().

In fact your {} brackets are in a mess. Try using AutoFormat (Ctrl-T) and that should help. You're continually defining functions inside other functions and that never works. Check that all function definitions start at the far left of the page, no spaces!

Steve

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [April 12, 2020, 11:46am UTC](https://forum.arduino.cc/t/a-function-definition-is-not-allowed-here-before-token/648207/3 "2020-04-12T11:46:51Z")

</div>

As pointed out, you're missing some }

After an autoformat, every function definition should (basically) start at the beginning of a line; that is, not be indented.

That will point you to the errors; below is your code (a little stripped) that shows the result after the autoformat.

```cpp
void setup() {
  ...
  ...
  void loop() {
    ...
    ...
    void motor_op(byte LM_dir, byte LM_spd, byte RM_dir, byte RM_spd)

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 12:26am UTC](https://forum.arduino.cc/t/a-function-definition-is-not-allowed-here-before-token/648207/4 "2021-05-06T00:26:51Z")

</div>

Closed on May 6, 2021, 12:26am UTC


