Skip to content

Commit

Permalink
Fix error with conflicting declaration of a prototype (Arduino sketch…
Browse files Browse the repository at this point in the history
… preprocessor)
  • Loading branch information
ivankravets committed Mar 20, 2019
1 parent d4af985 commit d9e6111
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Expand Up @@ -16,6 +16,7 @@ PlatformIO 3.0
3.6.6 (2019-??-??)
~~~~~~~~~~~~~~~~~~

* Fixed error with conflicting declaration of a prototype (Arduino sketch preprocessor)
* Fixed "FileExistsError" when `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ command is used in pair with ``--keep-build-dir`` option

3.6.5 (2019-03-07)
Expand Down
11 changes: 9 additions & 2 deletions platformio/builder/tools/piomisc.py
Expand Up @@ -33,10 +33,10 @@ class InoToCPPConverter(object):
PROTOTYPE_RE = re.compile(
r"""^(
(?:template\<.*\>\s*)? # template
([a-z_\d\&]+\*?\s+){1,2} # return type
([a-z_\d\&]+\*?\s+){1,2} # return type
([a-z_\d]+\s*) # name of prototype
\([a-z_,\.\*\&\[\]\s\d]*\) # arguments
)\s*\{ # must end with {
)\s*(\{|;) # must end with `{` or `;`
""", re.X | re.M | re.I)
DETECTMAIN_RE = re.compile(r"void\s+(setup|loop)\s*\(", re.M | re.I)
PROTOPTRS_TPLRE = r"\([^&\(]*&(%s)[^\)]*\)"
Expand Down Expand Up @@ -161,6 +161,13 @@ def append_prototypes(self, contents):
if not prototypes:
return contents

# skip already declared prototypes
declared = set(
m.group(1).strip() for m in prototypes if m.group(4) == ";")
prototypes = [
m for m in prototypes if m.group(1).strip() not in declared
]

prototype_names = set(m.group(3).strip() for m in prototypes)
split_pos = prototypes[0].start()
match_ptrs = re.search(
Expand Down
8 changes: 8 additions & 0 deletions tests/ino2cpp/basic/basic.ino
Expand Up @@ -49,4 +49,12 @@ void fooCallback(){

}

extern "C" {
void some_extern(const char *fmt, ...);
};

void some_extern(const char *fmt, ...) {

}

// юнікод

0 comments on commit d9e6111

Please sign in to comment.