Git Product home page Git Product logo

Comments (6)

aelliixx avatar aelliixx commented on May 24, 2024 1

I see. I never intended this library to work on windows, but perhaps that's a worthy idea nonetheless.

I don't have access to msvc myself, being on Linux, so the best I could do is make it compatible with mingw. Otherwise, I'm more than happy to take pull requests if you do find and fix the issue yourself :)

from cpp-inquirer.

aelliixx avatar aelliixx commented on May 24, 2024 1

Doh! Shouldn't use C-style unions anyway!
I think you're right, I don't expect the options vector to be terribly large and we don't have to worry so much about the memory these days anyway. So yeah, a quick fix would be moving those union members out of the union.
Long term we could use std::variant if we're keen on reducing the memory usage.

I'm happy to accept the patch if you do a PR :)

from cpp-inquirer.

aelliixx avatar aelliixx commented on May 24, 2024

Hey, thanks for the issue!
I tried replicating your problem on two different machines, however, I couldn't get it to not work.

Compiled with gcc on C++11, 14, 17, and 20, no issues as far as I could find.

Could you perhaps provide more details about what platform you're using, which compiler, and which C++ version?

In case it is a problem with the library, if you feel like delving into it and you know how to use the debugger, you could put a breakpoint on Inquirer::ask() and step through it to see why the function falls through. I'm more than happy to accept pull requests, but if not, some more details on your setup would be great so I could fix it myself.

Cheers!

from cpp-inquirer.

aelliixx avatar aelliixx commented on May 24, 2024

Closing due to not being able to replicate the issue and no response from the issue author

from cpp-inquirer.

MrSimsure avatar MrSimsure commented on May 24, 2024

Sorry for the disappear, i didn't had the time to investigate further on the problem, but after coming back and making some testing, i found out that the problem appear to arise when the project is compiled using MSVC, the visual studio compiler.
Compiling with gcc or clang seems to work as intended.
I'm gonna make some other test to find out what doesn't work with msvc.

from cpp-inquirer.

MrSimsure avatar MrSimsure commented on May 24, 2024

Found it!
Apparently it was the union type inside the Question class to cause the problem.
union { std::vector<std::string> options; std::string regex; };

if i remove the union so that options and regex are direct property of the class it works, don't know if this is a bug in MSVC or it is supposed to work differently.
From what i understand union is meant to reduce memory consumption by only making space for a specific property and not for both based on the constructor.
I already adapted the library to work on windows to suits my needs, so i can totally make a pull request for that, but for this specific MSVC problem what can be the best solution to fix it?

The simpler one would be to remove the union type, and trade memory for compatibility, it will compile under every main compiler this way, or maybe a #DEFINE rule to don't use the union only when the compiler is msvc, what do you think?

from cpp-inquirer.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.