User avatar
Alex_Landherr
Posts: 599
Joined: Mon May 18, 2020 3:14 pm
Location: Sweden

C++ - How to Check if No Flags Were Provided in Gflags?

Tue Aug 01, 2023 2:44 pm

I'm learning to use the gflags library from Google in my cmdline application and am wondering how to best check if no flags were passed?

Below is how my main.cpp currently looks:

Code: Select all

#include "include/prefixes.h"
#include "include/round_to.h"
#include "include/replace.h"
#include "include/timestamp.h"
#include "include/flags.h"
#include <iostream>
#include <filesystem>
#include <fstream>
#include <array>
#include <chrono>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    gflags::ParseCommandLineFlags(&argc, &argv, true);
    
    std::cout << "argc: " << argc << '\n';

    const std::array<uint64_t, 6> preset_byte_values = {1000, 1024, 1000000, 1048576, 1000000000, 1073741824};

    auto UTC_prog_start_time = std::chrono::system_clock::now();
    std::string test_file_name_str = "";
    try {
        test_file_name_str = replace::replace_char(' ', '_', timestamp::to_UTC(UTC_prog_start_time));
    } catch (const std::invalid_argument& ex) {
        std::cout << ex.what() << '\n';
    }

    std::string file_path_str = "test_files/File_Gen_Test_File_" + test_file_name_str + ".txt";

    if (argc > 1) {
        if (FLAGS_use_presets) {
            std::cout << "Using preset values." << '\n';
            //Using preset values.
            try {
                std::fstream test_fs{file_path_str, std::ios::out}; //Creating a file stream object to output to.
                test_fs.put('a'); //Puts a single character into the test file.
            } catch (const std::exception& e) {
                std::cout << e.what() << '\n';
            }

            std::filesystem::path path = file_path_str;
            try {
                std::filesystem::resize_file(path, preset_byte_values[FLAGS_byte_select]); //Resize file to specified size.
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (binary prefix): " << prefix::to_binary_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (decimal prefix): " << prefix::to_decimal_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }
        } else {
            std::cout << "Not using preset values." << '\n';
            //Not using preset values.
            try {
                std::fstream test_fs{file_path_str, std::ios::out}; //Creating a file stream object to output to.
                test_fs.put('a'); //Puts a single character into the test file.
            } catch (const std::exception& e) {
                std::cout << e.what() << '\n';
            }

            std::filesystem::path path = file_path_str;
            try {
                std::filesystem::resize_file(path, FLAGS_fsize); //Resize file to specified size.
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (binary prefix): " << prefix::to_binary_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (decimal prefix): " << prefix::to_decimal_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }
        }
    } else {
        std::cout << "No arguments were given." << '\n';
        std::exit(EXIT_FAILURE);
    }
    
    return 0;
}
And here's my code on GitHub with the present problem:
https://github.com/AlexLandherr/file_gen

Here's how it looks when I try to run it without any flags/arguments:

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen
argc: 1
Not using preset values.
File size (binary prefix): 0 B
File size (decimal prefix): 0 B
It should show the "No arguments were given." message and exit immediately, but as seen in the argc printout it's still only one argument which I understand is the "./file_gen" bit.

What am I doing wrong here? Should I use this method instead?:
https://stackoverflow.com/questions/542 ... mmand-line
Last edited by Alex_Landherr on Wed Aug 02, 2023 8:32 am, edited 1 time in total.
Helpful answers are appreciated.
I usually respond to Tweets directed at me.

3D Printer: Original Prusa Mini+ running OctoPi on a Pi4B 4GB.

OS:
  • Raspberry Pi OS
  • Windows 10
  • Ubuntu 22.04 LTS
Programming Languages:
  1. Python
  2. Java
  3. C++

User avatar
AndyD
Posts: 2414
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Wed Aug 02, 2023 8:59 am

I don't see how the code you have posted can produce the output you have shown. You are printing out argc and it is 1 (one), then your test is (argc > 1). There is nothing in your code between those two points that can be modifying the value of argc. Try re-compiling your code.

I couldn't compile your code as it has a number of headers that aren't available. I have a very cut down version of your code

Code: Select all

#include <iostream>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    gflags::ParseCommandLineFlags(&argc, &argv, true);

    std::cout << "argc: " << argc << '\n';

    if (argc > 1) {
        std::cout << argc << " arguments were given.\n";
    } else {
        std::cout << "No arguments were given.\n";
    }

    return 0;
}
outputs:

Code: Select all

argc: 1
No arguments were given.

User avatar
Alex_Landherr
Posts: 599
Joined: Mon May 18, 2020 3:14 pm
Location: Sweden

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Wed Aug 02, 2023 9:38 am

AndyD wrote:
Wed Aug 02, 2023 8:59 am
I don't see how the code you have posted can produce the output you have shown. You are printing out argc and it is 1 (one), then your test is (argc > 1). There is nothing in your code between those two points that can be modifying the value of argc. Try re-compiling your code.

I couldn't compile your code as it has a number of headers that aren't available. I have a very cut down version of your code

Code: Select all

#include <iostream>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    gflags::ParseCommandLineFlags(&argc, &argv, true);

    std::cout << "argc: " << argc << '\n';

    if (argc > 1) {
        std::cout << argc << " arguments were given.\n";
    } else {
        std::cout << "No arguments were given.\n";
    }

    return 0;
}
outputs:

Code: Select all

argc: 1
No arguments were given.
If you want to check my code in more detail see the Github link in OP.

I ran these steps:

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ make clean
rm obj/flags.o obj/main.o obj/prefixes.o obj/replace.o obj/round_to.o obj/timestamp.o flags.d main.d prefixes.d replace.d round_to.d timestamp.d file_gen
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ make
g++ -std=c++20 -Wall -o obj/flags.o -c src/flags.cpp
g++ -std=c++20 -Wall -o obj/main.o -c src/main.cpp
g++ -std=c++20 -Wall -o obj/prefixes.o -c src/prefixes.cpp
g++ -std=c++20 -Wall -o obj/replace.o -c src/replace.cpp
g++ -std=c++20 -Wall -o obj/round_to.o -c src/round_to.cpp
g++ -std=c++20 -Wall -o obj/timestamp.o -c src/timestamp.cpp
g++ -std=c++20 -Wall -o file_gen obj/flags.o obj/main.o obj/prefixes.o obj/replace.o obj/round_to.o obj/timestamp.o -l gflags
and still got this:

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen --use_presets -byte_select 0
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen -fsize 2048
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$
Helpful answers are appreciated.
I usually respond to Tweets directed at me.

3D Printer: Original Prusa Mini+ running OctoPi on a Pi4B 4GB.

OS:
  • Raspberry Pi OS
  • Windows 10
  • Ubuntu 22.04 LTS
Programming Languages:
  1. Python
  2. Java
  3. C++

User avatar
AndyD
Posts: 2414
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Wed Aug 02, 2023 9:56 am

Alex_Landherr wrote:
Wed Aug 02, 2023 9:38 am
and still got this:

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen --use_presets -byte_select 0
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen -fsize 2048
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$
This is a little different from your original post which had:-

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen
argc: 1
Not using preset values.
File size (binary prefix): 0 B
File size (decimal prefix): 0 B
Which didn't make sense to me how "Not using preset values." could be printed out by your code.

If you look at the information on https://gflags.github.io/gflags/ it described the effect of the third argument to ParseCommandLineFlags. If this is true, the passed in argc and argv variables are modified and the flags removed. If this is false, argc and argv are not changed.

One option would be to copy argc to another variable and pass that to ParseCommandLineFlags.

Code: Select all

#include <iostream>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    int argcc = argc;
    gflags::ParseCommandLineFlags(&argcc, &argv, true);

    std::cout << "argc: " << argc << '\n';

    if (argcc > argc) {
        std::cout << argcc - argc << " arguments were given.\n";
    } else {
        std::cout << "No arguments were given.\n";
    }

    return 0;
}

User avatar
Alex_Landherr
Posts: 599
Joined: Mon May 18, 2020 3:14 pm
Location: Sweden

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Wed Aug 02, 2023 10:06 am

AndyD wrote:
Wed Aug 02, 2023 9:56 am
If you look at the information on https://gflags.github.io/gflags/ it described the effect of the third argument to ParseCommandLineFlags. If this is true, the passed in argc and argv variables are modified and the flags removed. If this is false, argc and argv are not changed.

One option would be to copy argc to another variable and pass that to ParseCommandLineFlags.

Code: Select all

#include <iostream>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    int argcc = argc;
    gflags::ParseCommandLineFlags(&argcc, &argv, true);

    std::cout << "argc: " << argc << '\n';

    if (argcc > argc) {
        std::cout << argcc - argc << " arguments were given.\n";
    } else {
        std::cout << "No arguments were given.\n";
    }

    return 0;
}
Output with your changes:

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ make clean
rm obj/flags.o obj/main.o obj/prefixes.o obj/replace.o obj/round_to.o obj/timestamp.o flags.d main.d prefixes.d replace.d round_to.d timestamp.d file_gen
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ make
g++ -std=c++20 -Wall -o obj/flags.o -c src/flags.cpp
g++ -std=c++20 -Wall -o obj/main.o -c src/main.cpp
g++ -std=c++20 -Wall -o obj/prefixes.o -c src/prefixes.cpp
g++ -std=c++20 -Wall -o obj/replace.o -c src/replace.cpp
g++ -std=c++20 -Wall -o obj/round_to.o -c src/round_to.cpp
g++ -std=c++20 -Wall -o obj/timestamp.o -c src/timestamp.cpp
g++ -std=c++20 -Wall -o file_gen obj/flags.o obj/main.o obj/prefixes.o obj/replace.o obj/round_to.o obj/timestamp.o -l gflags
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen -fsize 2048
argc: 3
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen --use_presets -byte_select 0
argc: 4
No arguments were given.
and main.cpp.

Code: Select all

#include "include/prefixes.h"
#include "include/round_to.h"
#include "include/replace.h"
#include "include/timestamp.h"
#include "include/flags.h"
#include <iostream>
#include <filesystem>
#include <fstream>
#include <array>
#include <chrono>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    int argcc = argc;
    gflags::ParseCommandLineFlags(&argcc, &argv, true);
    
    std::cout << "argc: " << argc << '\n';

    const std::array<uint64_t, 6> preset_byte_values = {1000, 1024, 1000000, 1048576, 1000000000, 1073741824};

    auto UTC_prog_start_time = std::chrono::system_clock::now();
    std::string test_file_name_str = "";
    try {
        test_file_name_str = replace::replace_char(' ', '_', timestamp::to_UTC(UTC_prog_start_time));
    } catch (const std::invalid_argument& ex) {
        std::cout << ex.what() << '\n';
    }

    std::string file_path_str = "test_files/File_Gen_Test_File_" + test_file_name_str + ".txt";

    if (argcc > argc) {
        std::cout << argcc - argc << " arguments were given.\n";
        if (FLAGS_use_presets) {
            std::cout << "Using preset values." << '\n';
            //Using preset values.
            try {
                std::fstream test_fs{file_path_str, std::ios::out}; //Creating a file stream object to output to.
                test_fs.put('a'); //Puts a single character into the test file.
            } catch (const std::exception& e) {
                std::cout << e.what() << '\n';
            }

            std::filesystem::path path = file_path_str;
            try {
                std::filesystem::resize_file(path, preset_byte_values[FLAGS_byte_select]); //Resize file to specified size.
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (binary prefix): " << prefix::to_binary_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (decimal prefix): " << prefix::to_decimal_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }
        } else {
            std::cout << "Not using preset values." << '\n';
            //Not using preset values.
            try {
                std::fstream test_fs{file_path_str, std::ios::out}; //Creating a file stream object to output to.
                test_fs.put('a'); //Puts a single character into the test file.
            } catch (const std::exception& e) {
                std::cout << e.what() << '\n';
            }

            std::filesystem::path path = file_path_str;
            try {
                std::filesystem::resize_file(path, FLAGS_fsize); //Resize file to specified size.
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (binary prefix): " << prefix::to_binary_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (decimal prefix): " << prefix::to_decimal_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }
        }
    } else {
        std::cout << "No arguments were given." << '\n';
        std::exit(EXIT_FAILURE);
    }
    
    return 0;
}
Helpful answers are appreciated.
I usually respond to Tweets directed at me.

3D Printer: Original Prusa Mini+ running OctoPi on a Pi4B 4GB.

OS:
  • Raspberry Pi OS
  • Windows 10
  • Ubuntu 22.04 LTS
Programming Languages:
  1. Python
  2. Java
  3. C++

User avatar
AndyD
Posts: 2414
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Wed Aug 02, 2023 10:18 am

Yes sorry I got that test around the wrong way ...

Code: Select all

#include <iostream>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    int argcc = argc;
    gflags::ParseCommandLineFlags(&argcc, &argv, true);

    std::cout << "argc: " << argc << '\n';

    if (argc > argcc) {
        std::cout << argc - argcc << " arguments were given.\n";
    } else {
        std::cout << "No arguments were given.\n";
    }

    return 0;
}

User avatar
Alex_Landherr
Posts: 599
Joined: Mon May 18, 2020 3:14 pm
Location: Sweden

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Wed Aug 02, 2023 10:38 am

AndyD wrote:
Wed Aug 02, 2023 10:18 am
Yes sorry I got that test around the wrong way ...

Code: Select all

#include <iostream>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    int argcc = argc;
    gflags::ParseCommandLineFlags(&argcc, &argv, true);

    std::cout << "argc: " << argc << '\n';

    if (argc > argcc) {
        std::cout << argc - argcc << " arguments were given.\n";
    } else {
        std::cout << "No arguments were given.\n";
    }

    return 0;
}
main.cpp:

Code: Select all

#include "include/prefixes.h"
#include "include/round_to.h"
#include "include/replace.h"
#include "include/timestamp.h"
#include "include/flags.h"
#include <iostream>
#include <filesystem>
#include <fstream>
#include <array>
#include <chrono>
#include <gflags/gflags.h>

int main(int argc, char *argv[]) {
    int argcc = argc;
    gflags::ParseCommandLineFlags(&argcc, &argv, true);
    
    std::cout << "argc: " << argc << '\n';

    const std::array<uint64_t, 6> preset_byte_values = {1000, 1024, 1000000, 1048576, 1000000000, 1073741824};

    auto UTC_prog_start_time = std::chrono::system_clock::now();
    std::string test_file_name_str = "";
    try {
        test_file_name_str = replace::replace_char(' ', '_', timestamp::to_UTC(UTC_prog_start_time));
    } catch (const std::invalid_argument& ex) {
        std::cout << ex.what() << '\n';
    }

    std::string file_path_str = "test_files/File_Gen_Test_File_" + test_file_name_str + ".txt";

    if (argc > argcc) {
        std::cout << argcc - argc << " arguments were given.\n";
        if (FLAGS_use_presets) {
            std::cout << "Using preset values." << '\n';
            //Using preset values.
            try {
                std::fstream test_fs{file_path_str, std::ios::out}; //Creating a file stream object to output to.
                test_fs.put('a'); //Puts a single character into the test file.
            } catch (const std::exception& e) {
                std::cout << e.what() << '\n';
            }

            std::filesystem::path path = file_path_str;
            try {
                std::filesystem::resize_file(path, preset_byte_values[FLAGS_byte_select]); //Resize file to specified size.
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (binary prefix): " << prefix::to_binary_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (decimal prefix): " << prefix::to_decimal_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }
        } else {
            std::cout << "Not using preset values." << '\n';
            //Not using preset values.
            try {
                std::fstream test_fs{file_path_str, std::ios::out}; //Creating a file stream object to output to.
                test_fs.put('a'); //Puts a single character into the test file.
            } catch (const std::exception& e) {
                std::cout << e.what() << '\n';
            }

            std::filesystem::path path = file_path_str;
            try {
                std::filesystem::resize_file(path, FLAGS_fsize); //Resize file to specified size.
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (binary prefix): " << prefix::to_binary_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }

            try {
                std::cout << "File size (decimal prefix): " << prefix::to_decimal_prefix(std::filesystem::file_size(path)) << '\n';
            } catch (const std::filesystem::filesystem_error& e) {
                std::cout << e.what() << '\n';
            } catch (const std::invalid_argument& e) {
                std::cout << e.what() << '\n';
            }
        }
    } else {
        std::cout << "No arguments were given." << '\n';
        std::exit(EXIT_FAILURE);
    }
    
    return 0;
}
and output:

Code: Select all

alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ make clean
rm obj/flags.o obj/main.o obj/prefixes.o obj/replace.o obj/round_to.o obj/timestamp.o flags.d main.d prefixes.d replace.d round_to.d timestamp.d file_gen
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ make
g++ -std=c++20 -Wall -o obj/flags.o -c src/flags.cpp
g++ -std=c++20 -Wall -o obj/main.o -c src/main.cpp
g++ -std=c++20 -Wall -o obj/prefixes.o -c src/prefixes.cpp
g++ -std=c++20 -Wall -o obj/replace.o -c src/replace.cpp
g++ -std=c++20 -Wall -o obj/round_to.o -c src/round_to.cpp
g++ -std=c++20 -Wall -o obj/timestamp.o -c src/timestamp.cpp
g++ -std=c++20 -Wall -o file_gen obj/flags.o obj/main.o obj/prefixes.o obj/replace.o obj/round_to.o obj/timestamp.o -l gflags
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen
argc: 1
No arguments were given.
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen -fsize 2048
argc: 3
-2 arguments were given.
Not using preset values.
File size (binary prefix): 2.00 KiB
File size (decimal prefix): 2.05 kB
alexl@PD70PNP:/mnt/Storage_SSD/C++_Projects/file_gen$ ./file_gen --use_presets -byte_select 0
argc: 4
-3 arguments were given.
Using preset values.
File size (binary prefix): 1000 B
File size (decimal prefix): 1.00 kB
I take it I should keep it like this or are there any other improvements to be made?

EDIT: I opened an issue on the gflags repo about this: https://github.com/gflags/gflags/issues/351
Helpful answers are appreciated.
I usually respond to Tweets directed at me.

3D Printer: Original Prusa Mini+ running OctoPi on a Pi4B 4GB.

OS:
  • Raspberry Pi OS
  • Windows 10
  • Ubuntu 22.04 LTS
Programming Languages:
  1. Python
  2. Java
  3. C++

swampdog
Posts: 1178
Joined: Fri Dec 04, 2015 11:22 am

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Thu Aug 03, 2023 10:00 pm

Out of curiosity, what led you to try glags? I'd not heard of it until you posted - gflags seems a little wierd! ;-)

User avatar
Alex_Landherr
Posts: 599
Joined: Mon May 18, 2020 3:14 pm
Location: Sweden

Re: C++ - How to Check if No Flags Were Provided in Gflags?

Fri Sep 29, 2023 9:18 am

swampdog wrote:
Thu Aug 03, 2023 10:00 pm
Out of curiosity, what led you to try glags? I'd not heard of it until you posted - gflags seems a little wierd! ;-)
It was the one library I found that had a beginner-friendly tutorial from its creators.
Helpful answers are appreciated.
I usually respond to Tweets directed at me.

3D Printer: Original Prusa Mini+ running OctoPi on a Pi4B 4GB.

OS:
  • Raspberry Pi OS
  • Windows 10
  • Ubuntu 22.04 LTS
Programming Languages:
  1. Python
  2. Java
  3. C++

Return to “C/C++”