Fix error with conflicting declaration of a prototype (Arduino sketch preprocessor)

This commit is contained in:
Ivan Kravets
2019-03-20 18:49:20 +02:00
parent 86e4641101
commit d7e2d05f60
3 changed files with 19 additions and 3 deletions

View File

@@ -7,6 +7,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)

View File

@@ -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)[^\)]*\)"
@@ -162,7 +162,14 @@ class InoToCPPConverter(object):
if not prototypes:
return contents
prototype_names = set([m.group(3).strip() for m in prototypes])
# 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(
self.PROTOPTRS_TPLRE % ("|".join(prototype_names)),

View File

@@ -49,4 +49,12 @@ void fooCallback(){
}
extern "C" {
void some_extern(const char *fmt, ...);
};
void some_extern(const char *fmt, ...) {
}
// юнікод