|
| 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 · PGraphics needs to be a pointer</a><a href="E0002.html" class="">E0002 · PImage needs to be a pointer</a><a href="E0003.html" class="">E0003 · PShader needs to be a pointer</a><a href="E0004.html" class="">E0004 · Java-style array declarations aren't supported</a><a href="E0005.html" class="">E0005 · ArrayList.get() returns a pointer, not a value</a><a href="E0006.html" class="">E0006 · Java static access syntax not valid in C++</a><a href="E0007.html" class="active">E0007 · 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'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't resolve.</p> |
| 58 | + <h2>How to fix it</h2> |
| 59 | + <p>Rename the variable to something that doesn'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 "using namespace Processing" 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> |
0 commit comments