Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] cpp2::move(std)::cout suddenly appears #1321

Open
MatthieuHernandez opened this issue Oct 21, 2024 · 2 comments
Open

[BUG] cpp2::move(std)::cout suddenly appears #1321

MatthieuHernandez opened this issue Oct 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@MatthieuHernandez
Copy link
Contributor

MatthieuHernandez commented Oct 21, 2024

Sorry but I won't be able to give much info as this bug seems to appear “randomly”.
Sometimes I'll add a valid line of code to a method and another function in my code (always the same) will start being generated in the wrong way.
It's impossible to reproduce this bug in an MRE, because it's incomprehensible. I once had this bug and adding this line count = count + 0;, in the method I was working on made it go away.

Sometime this method:

printMenu:() = {
    clear();
    std::cout << "**************************************************" << std::endl;
    std::cout << "*                   GOPP2 Menu                   *" << std::endl;
    std::cout << "**************************************************" << std::endl;
    std::cout << "* Please select one of the following:            *" << std::endl;
    std::cout << "*                                                *" << std::endl;
    std::cout << "*     1. Start a game                            *" << std::endl;
    std::cout << "*     2. Exit                                    *" << std::endl;
    std::cout << "**************************************************" << std::endl;
    std::cout << std::endl << getNextMessage() << std::endl;
}

Is generated like this for no apparent reason:

auto printMenu() -> void{
    clear();
    std::cout << "**************************************************" << std::endl;
    std::cout << "*                   GOPP2 Menu                   *" << std::endl;
    std::cout << "**************************************************" << std::endl;
    std::cout << "* Please select one of the following:            *" << std::endl;
    cpp2::move(std)::cout << "*                                                *" << std::endl;
    std::cout << "*     1. Start a game                            *" << std::endl;
    std::cout << "*     2. Exit                                    *" << std::endl;
    std::cout << "**************************************************" << std::endl;
    std::cout << std::endl << getNextMessage() << std::endl;
}

Why does cpp2::move(std)::cout is generated?
I don't have any explanation, I'll let you know if I get any new information on this.

@MatthieuHernandez MatthieuHernandez added the bug Something isn't working label Oct 21, 2024
@MatthieuHernandez
Copy link
Contributor Author

I think I've found a solution to my problem. I mustn't run cppfront on all my files at the same time in my building script.

This generates cpp1 code that does not compile:

cppfront -cwd ./generate ../src/color.h2 |
cppfront -cwd ./generate `
    ../src/stone.h2 `
    ../src/goban.h2 `
    ../src/move.h2 `
    ../src/game.h2 `
    ../src/engine.h2 `
    ../src/io.h2 `
    ../src/main.cpp2 `
    -import-std

While it generates the expected code

cppfront -cwd ./generate ../src/color.h2 |
cppfront -cwd ./generate ../src/stone.h2 ../src/goban.h2 ../src/move.h2 -import-std |
cppfront -cwd ./generate ../src/game.h2 ../src/engine.h2 ../src/io.h2 -import-std |
cppfront -cwd ./generate ../src/main.cpp2 -import-std

@DyXel
Copy link
Contributor

DyXel commented Oct 21, 2024

Sounds like an issue with globals usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants