# Expected unqualified-id before '(' token caused by #include \<vector\>

**URL:** <https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744>\
**Category:** Troubleshooting\
**Created:** [June 28, 2019, 5:01pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744 "2019-06-28T17:01:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![poolnoodle](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@poolnoodle](https://community.particle.io/u/poolnoodle)\
**Post date:** [June 28, 2019, 5:01pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/1 "2019-06-28T17:01:22Z")

</div>

I was trying to write a very simple function to read ADC 20 times, remove min and max and find the average. I stored the readings in a std::vector arr, but this error keeps showing up

> ../wiring/inc/spark\_wiring\_arduino\_constants.h:111:18: expected unqualified-id before '(' token

I realized even only include the "vector" library and not do anything else would still give the same error.

Here's my code. I commented out the function that has vectors in it. But even this is giving me error.

```auto
#include "ADS1015_async.h"
#include "application.h"
#include "MCP4728.h"
#include "math.h"
#undef swap
#include "vector"
//using namespace std;
//std::vector<int> arr;

```

Once I comment out

> #include "vector"

everything compiles.

---

<div class="post-metadata">

**Author:** ![Muskie](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/muskie/32/4044_2.png) [@Muskie](https://community.particle.io/u/Muskie)\
**Post date:** [June 28, 2019, 5:24pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/2 "2019-06-28T17:24:22Z")

</div>

Have you tried this?

```auto
#include <vector>

```

---

<div class="post-metadata">

**Author:** ![poolnoodle](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@poolnoodle](https://community.particle.io/u/poolnoodle)\
**Post date:** [June 28, 2019, 5:36pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/3 "2019-06-28T17:36:26Z")

</div>

Yes I tried both.

---

<div class="post-metadata">

**Author:** ![Muskie](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/muskie/32/4044_2.png) [@Muskie](https://community.particle.io/u/Muskie)\
**Post date:** [June 28, 2019, 6:02pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/4 "2019-06-28T18:02:28Z")

</div>

The error is pointing to an include file from the system. ScruffR posted a bug report on this error here:

> <https://github.com/particle-iot/device-os/issues/1470>

If this is the same error regarding the max macro, then try undefining that macro prior to including the header for vector.

---

<div class="post-metadata">

**Author:** ![poolnoodle](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@poolnoodle](https://community.particle.io/u/poolnoodle)\
**Post date:** [June 28, 2019, 6:15pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/5 "2019-06-28T18:15:25Z")

</div>

Hi Thanks for the reply. But I didn’t use the max macro in the code. I didn’t define anything in my code actually.

---

<div class="post-metadata">

**Author:** ![Muskie](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/muskie/32/4044_2.png) [@Muskie](https://community.particle.io/u/Muskie)\
**Post date:** [June 28, 2019, 6:32pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/6 "2019-06-28T18:32:58Z")

</div>

You don’t have to have used it. The standard library contains a definition of max (and min) that would conflict with one in the constants header. Just including the vector header could cause a clash.

I’m not sure if this is definitely the problem, but based on ScruffR’s bug report you should look into it carefully. Try:

```auto
#undef max
#include <vector>

```

Note that there may be other conflicts to deal with such as min.

---

<div class="post-metadata">

**Author:** ![poolnoodle](https://avatars.discourse-cdn.com/v4/letter/p/f08c70/32.png) [@poolnoodle](https://community.particle.io/u/poolnoodle)\
**Post date:** [June 28, 2019, 6:36pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/7 "2019-06-28T18:36:46Z")

</div>

ohhhh It did compile thank you so much!!

---

<div class="post-metadata">

**Author:** ![TrikkStar](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@TrikkStar](https://community.particle.io/u/TrikkStar)\
**Post date:** [November 1, 2019, 5:15pm UTC](https://community.particle.io/t/expected-unqualified-id-before-token-caused-by-include-vector/50744/8 "2019-11-01T17:15:35Z")

</div>

Has there been any progress on fixing this issue? I’m trying to switch a project using lists to vectors and the provided fix isn’t working for me.
