Result of `BOOST_PP_ARRAY_ELEM` can't be included in vs2017 using `/experimental:preprocessor` option

Open
#25 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
compilers

Research direction

Reproduce the shown macro example with VS2017 and /experimental:preprocessor, then inspect <boost/preprocessor/iteration/detail/iter/forward1.hpp> and its use from <boost/function.hpp>. Done means the affected include directives compile under VS2017 while preserving the existing behavior on VS2019.

Written by the indexing model from the issue text.

Description

The following code does not compile under VS2017 using /experimental:preprocessor option:

#include <iostream>
#include <boost/preprocessor.hpp>

#define FOO (1,(<type_traits>))
#define BAR BOOST_PP_ARRAY_ELEM(0, FOO)

#define HOGE_1(x) x
#define HOGE_2(x) HOGE_1(x)
#define HOGE() HOGE_2(BAR)
#define PUYO_1(x) #x
#define PUYO_2(x) PUYO_1(x)
#define PUYO() PUYO_2(BAR)

#include BAR  //C2006
#include HOGE()  //C2006

int main(){
    std::cout << PUYO() << std::endl;
    return 0;
}

Both #include BAR and #include HOGE() directives result in C2006 error, yet, PUYO macro could successfully get the string literal formed by BAR.
Switching to vs2019 eliminates this issue.

This issue breaks the usage of <boost/preprocessor/iteration/detail/iter/forward1.hpp> in `<boost/function.hpp>

Dominant language
C++
Stars
118
Forks
76
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/preprocessor

All issues in boostorg/preprocessor

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.