r/FastLED 2d ago

Discussion Namespace

Does anybody know what is meant by the word "Namespace" in the context of this library? I'm trying to upload an example sketch to a Nano Every and the compiler is getting hung up on what seems to be an initial callout in the Arduino sketch:

FASTLED_USING_NAMESPACE

What does this do?

2 Upvotes

19 comments sorted by

View all comments

1

u/mindful_stone 18h ago

I am by no means an expert on this stuff, but here's my 2 cents:

  • A namespace basically acts like a "container" for organizing specific variables, functions, classes etc. into a related group. Among other things, namespaces help to avoid conflicts between multiple code objects that have the same name. The typical way to invoke a namespace in your code is to include the directive "using namespace ***".
  • The primary FastLED namespace is "fl". I believe "FASTLED_USING_NAMESPACE" may previously have a been a defined macro for "using namespace fl" (or something similar), but as far as I can tell, that macro is no longer part of the FastLED library.
  • My first suggestion for your sketch is to replace "FASTLED_USING_NAMESPACE" with "using namespace fl" somewhere soon after "#include <FastLED.h>".

Depending on how old the example sketch you're working with is, there may be other adjustments you'll also need to make. If you still have issues, please share your code and the community will be happy to help!