Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2016-2023 simplecpp team
*/

#define SIMPLECPP_TOKENLIST_ALLOW_PTR 0
#include "simplecpp.h"

#include <cstdlib>
Expand Down
6 changes: 4 additions & 2 deletions simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
#ifndef SIMPLECPP_TOKENLIST_ALLOW_PTR
// still provide the legacy API in case we lack the performant wrappers
# if !defined(__cpp_lib_string_view) && !defined(__cpp_lib_span)
# define SIMPLECPP_TOKENLIST_ALLOW_PTR
# define SIMPLECPP_TOKENLIST_ALLOW_PTR 1
# else
# define SIMPLECPP_TOKENLIST_ALLOW_PTR 0
# endif
#endif

Expand Down Expand Up @@ -267,7 +269,7 @@ namespace simplecpp {
TokenList(const unsigned char (&data)[size], std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
: TokenList(data, size-1, filenames, filename, outputList, 0)
{}
#ifdef SIMPLECPP_TOKENLIST_ALLOW_PTR
#if SIMPLECPP_TOKENLIST_ALLOW_PTR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this macro is optional, I have the feeling it's better to write:

Suggested change
#if SIMPLECPP_TOKENLIST_ALLOW_PTR
#if defined(SIMPLECPP_TOKENLIST_ALLOW_PTR) && SIMPLECPP_TOKENLIST_ALLOW_PTR

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what the standard says about this condition if the macro is not defined.

Copy link
Collaborator Author

@firewave firewave Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code above will make sure it is always defined.

/** generates a token list from the given buffer */
TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
: TokenList(data, size, filenames, filename, outputList, 0)
Expand Down