Skip to content

Commit 2833e1b

Browse files
committed
add E0007 error page: variable name shadows Processing type
1 parent 8cf0e34 commit 2833e1b

9 files changed

Lines changed: 109 additions & 7 deletions

File tree

assets/errors.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,33 @@
154154
PFont, PVector, PShape, and PGraphics even though they start with an
155155
uppercase letter. For your own classes, use :: for anything declared
156156
static and . only on an actual instance. Related: E0004, E0005.
157+
- code: E0007
158+
title: Variable name shadows a Processing type
159+
type: Compiler Error
160+
summary: >
161+
The variable name you used matches a type or name that CppMode pulls into
162+
scope automatically. The confirmed case is color — when you write
163+
int color = 255, CppMode's type-fixing pass later rewrites the declaration
164+
to color color = 255, which is a type-redeclaration error and crashes the
165+
build. Even without that rewrite, using color as a variable name in any
166+
scope where Processing::color is visible causes ambiguity the compiler
167+
can't resolve.
168+
fix: >
169+
Rename the variable to something that doesn't clash with the Processing
170+
API. For color, the usual alternatives are col, clr, or c.
171+
before: |
172+
int color = 255;
173+
fill(color);
174+
after: |
175+
int col = 255;
176+
fill(col);
177+
notes: >
178+
CppMode uses a global "using namespace Processing" which pulls in
179+
everything at once — types like color and PVector, functions like fill,
180+
noise, and line, and constants like PI and TWO_PI. In principle any of
181+
those names could shadow a variable you define. In practice only color
182+
is a confirmed crasher right now, which is why E0007 only flags that one
183+
name. If you hit a similar ambiguity with a different name, renaming the
184+
variable is always the fix. The long-term solution is scoping the
185+
namespace import inside the sketch struct rather than at global scope,
186+
but that is a larger engine change. Related: E0005, E0006.

error/E0001.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="layout">
4949
<div class="sidebar-outer">
5050
<div id="site-sidebar"></div>
51-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="active">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="active">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
5252
</div>
5353
<div class="content">
5454
<h1>E0001: PGraphics needs to be a pointer</h1>

error/E0002.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="layout">
4949
<div class="sidebar-outer">
5050
<div id="site-sidebar"></div>
51-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="active">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="active">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
5252
</div>
5353
<div class="content">
5454
<h1>E0002: PImage needs to be a pointer</h1>

error/E0003.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="layout">
4949
<div class="sidebar-outer">
5050
<div id="site-sidebar"></div>
51-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="active">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="active">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
5252
</div>
5353
<div class="content">
5454
<h1>E0003: PShader needs to be a pointer</h1>

error/E0004.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="layout">
4949
<div class="sidebar-outer">
5050
<div id="site-sidebar"></div>
51-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="active">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="active">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
5252
</div>
5353
<div class="content">
5454
<h1>E0004: Java-style array declarations aren&#x27;t supported</h1>

error/E0005.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="layout">
4949
<div class="sidebar-outer">
5050
<div id="site-sidebar"></div>
51-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="active">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="active">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
5252
</div>
5353
<div class="content">
5454
<h1>E0005: ArrayList.get() returns a pointer, not a value</h1>

error/E0006.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="layout">
4949
<div class="sidebar-outer">
5050
<div id="site-sidebar"></div>
51-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="active">E0006 &middot; Java static access syntax not valid in C++</a></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="active">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
5252
</div>
5353
<div class="content">
5454
<h1>E0006: Java static access syntax not valid in C++</h1>

error/E0007.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>E0007: Variable name shadows a Processing type - Processing for C++</title>
7+
<style>* { margin: 0; padding: 0; box-sizing: border-box; }
8+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #111; background: #fff; }
9+
a { color: #111; text-decoration: none; }
10+
nav { border-bottom: 1px solid #e0e0e0; padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; height: 60px; position: sticky; top: 0; background: #fff; z-index: 100; }
11+
.nav-logo { display: flex; align-items: center; gap: 10px; color: #111; }
12+
.nav-logo img { width: 28px; height: 28px; }
13+
.hamburger { background: none; border: none; cursor: pointer; font-size: 22px; padding: 4px 8px; display: none; }
14+
.layout { display: flex; min-height: calc(100vh - 60px); }
15+
.sidebar-outer { width: 220px; min-width: 220px; border-right: 1px solid #e0e0e0; display: flex; flex-direction: column; position: sticky; top: 60px; height: calc(100vh - 60px); }
16+
#site-sidebar { padding: 1.5rem 1.5rem 1rem; border-bottom: 1px solid #e0e0e0; display: flex; flex-direction: column; }
17+
#site-sidebar a { font-size: 14px; color: #555; padding: 0.4rem 0; display: block; }
18+
#site-sidebar a:hover { color: #111; }
19+
#site-sidebar a.active { color: #111; font-weight: 500; }
20+
.err-sidebar { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
21+
.err-sidebar-title { font-size: 11px; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.85rem 1.5rem 0.25rem; }
22+
.err-sidebar a { display: block; font-size: 12px; color: #555; padding: 0.25rem 1.5rem; font-family: "SF Mono","Fira Code",monospace; }
23+
.err-sidebar a:hover { color: #111; background: #f8f8f8; }
24+
.err-sidebar a.active { color: #111 !important; font-weight: 600; background: #f4f4f4; }
25+
.content { flex: 1; padding: 3rem 4rem; max-width: 820px; }
26+
.content h1 { font-size: 1.6rem; font-weight: 600; margin-bottom: 0.25rem; font-family: "SF Mono","Fira Code",monospace; }
27+
.err-code { font-size: 12px; color: #aaa; margin-bottom: 2rem; display: block; font-family: "SF Mono","Fira Code",monospace; }
28+
.content h2 { font-size: 11px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2rem; margin-bottom: 0.75rem; }
29+
.content p { color: #444; line-height: 1.8; margin-bottom: 1rem; font-size: 0.95rem; }
30+
.code-block { background: #f8f8f8; border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 0.5rem; font-family: "SF Mono","Fira Code",monospace; font-size: 13px; line-height: 1.8; white-space: pre; overflow-x: auto; }
31+
.code-block.before { border-left: 3px solid #d4534f; }
32+
.code-block.after { border-left: 3px solid #2f9e5c; }
33+
.code-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; display: block; }
34+
.code-label.before { color: #d4534f; }
35+
.code-label.after { color: #2f9e5c; }
36+
.code-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 0.5rem; }
37+
footer { border-top: 1px solid #e0e0e0; padding: 2rem; text-align: center; font-size: 13px; color: #888; }
38+
@media (max-width: 768px) {
39+
.hamburger { display: block; }
40+
.sidebar-outer { position: fixed; top: 60px; left: -240px; width: 240px; height: calc(100vh - 60px); background: #fff; z-index: 200; transition: left 0.25s ease; box-shadow: 2px 0 12px rgba(0,0,0,0.08); }
41+
.sidebar-outer.open { left: 0; }
42+
.content { padding: 2rem 1.25rem; }
43+
.code-pair { grid-template-columns: 1fr; }
44+
}</style>
45+
</head>
46+
<body>
47+
<nav id="site-nav"></nav>
48+
<div class="layout">
49+
<div class="sidebar-outer">
50+
<div id="site-sidebar"></div>
51+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="active">E0007 &middot; Variable name shadows a Processing type</a></div>
52+
</div>
53+
<div class="content">
54+
<h1>E0007: Variable name shadows a Processing type</h1>
55+
<span class="err-code">Compiler Error</span>
56+
<h2>What it means</h2>
57+
<p>The variable name you used matches a type or name that CppMode pulls into scope automatically. The confirmed case is color — when you write int color = 255, CppMode&#x27;s type-fixing pass later rewrites the declaration to color color = 255, which is a type-redeclaration error and crashes the build. Even without that rewrite, using color as a variable name in any scope where Processing::color is visible causes ambiguity the compiler can&#x27;t resolve.</p>
58+
<h2>How to fix it</h2>
59+
<p>Rename the variable to something that doesn&#x27;t clash with the Processing API. For color, the usual alternatives are col, clr, or c.</p>
60+
<h2>Example</h2><div class="code-pair"><div><span class="code-label before">Before</span><div class="code-block before">int color = 255;
61+
fill(color);</div></div><div><span class="code-label after">After</span><div class="code-block after">int col = 255;
62+
fill(col);</div></div></div>
63+
<h2>Notes</h2><p>CppMode uses a global &quot;using namespace Processing&quot; which pulls in everything at once — types like color and PVector, functions like fill, noise, and line, and constants like PI and TWO_PI. In principle any of those names could shadow a variable you define. In practice only color is a confirmed crasher right now, which is why E0007 only flags that one name. If you hit a similar ambiguity with a different name, renaming the variable is always the fix. The long-term solution is scoping the namespace import inside the sketch struct rather than at global scope, but that is a larger engine change. Related: E0005, E0006.</p>
64+
</div>
65+
</div>
66+
<footer><p>Processing for C++</p></footer>
67+
<script src="../assets/nav.js"></script>
68+
</body>
69+
</html>

error/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<div class="layout">
5959
<div class="sidebar-outer">
6060
<div id="site-sidebar"></div>
61-
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a></div>
61+
<div class="err-sidebar"><div class="err-sidebar-title">Compiler Errors</div><a href="E0001.html" class="">E0001 &middot; PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 &middot; PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 &middot; PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 &middot; Java-style array declarations aren&#x27;t supported</a><a href="E0005.html" class="">E0005 &middot; ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 &middot; Java static access syntax not valid in C++</a><a href="E0007.html" class="">E0007 &middot; Variable name shadows a Processing type</a></div>
6262
</div>
6363
<div class="content">
6464
<h1>Processing C++ error codes index</h1>
@@ -81,6 +81,9 @@ <h1>Processing C++ error codes index</h1>
8181
</a><a href="E0006.html" class="err-list-item">
8282
<span class="err-list-code">E0006</span>
8383
<span class="err-list-title">Java static access syntax not valid in C++</span>
84+
</a><a href="E0007.html" class="err-list-item">
85+
<span class="err-list-code">E0007</span>
86+
<span class="err-list-title">Variable name shadows a Processing type</span>
8487
</a>
8588
</div>
8689
</div>

0 commit comments

Comments
 (0)