recentpopularlog in

kme : cplusplus   290

« earlier  
adishavit/argh: Argh! A minimalist argument handler.
It doesn't get much simpler than this:
<code class="language-cpp">
#include <iostream>
#include "argh.h"

int main(int, char* argv[])
argh::parser cmdl(argv);

if (cmdl[{ "-v", "--verbose" }])
std::cout << "Verbose, I am.\n";

cplusplus  argumentparsing  argparse  singlefile  hpp  library 
12 weeks ago by kme
nothings/stb: stb single-file public domain libraries for C/C++
I still use MSVC 6 (1998) as my IDE because it has better human factors for me than later versions of MSVC.
c  cplusplus  headers  imageprocessing  graphics  publicdomain  mit  library 
12 weeks ago by kme
NASA-SW-VnV/ikos: Static analyzer for C/C++ based on the theory of Abstract Interpretation.
Static analyzer for C/C++ based on the theory of Abstract Interpretation. - NASA-SW-VnV/ikos
c  cplusplus  staticanalyzer  devel 
may 2019 by kme
alexhsamuel/fixfmt: Fixed-width formatters. |
Fixed-width formatters. Contribute to alexhsamuel/fixfmt development by creating an account on GitHub.
python  cplusplus  data  library 
march 2019 by kme
libmysql - Cheapest way to to determine if a MySQL connection is still alive - Stack Overflow |
In this case you can use 'DO 1' as an alternative to SELECT 1; it is marginally faster -- shorter to parse, and it does not return actual data (although you will get the TCP acks, so you will still do the roundtrip validating that the connection is still established.)
mysql  mysqlcppconn  dba  devel  cplusplus  solution 
february 2019 by kme
Baltasarq/cscrutil: Multiplatform screen console management for C |
Multiplatform screen console management for C. Contribute to Baltasarq/cscrutil development by creating an account on GitHub.
c  cplusplus  ansi  colors  ansicolors  console  cli  commandline  library  maybesolution 
february 2019 by kme
Cscope Home Page |
Try: 'ag -l --cpp | cscope -i- -b -q' (build cross-ref, inverted index)
devel  c  cplusplus  codesearch  crossreference  commandline  vim  asanide  solution 
february 2019 by kme
linux - How to install `build-essential` in `Cygwin`? - Stack Overflow |
Build-essential is a collection of packages. So you'll have to select the packages manually, which I believe are the following:

- make
- automake
- gcc
- gcc-c++
windows  cygwin  devel  build  toolchain  gcc  cplusplus  maybesolution  likedebian 
june 2018 by kme
uncrustify/uncrustify: Code beautifier
Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA
devel  cplusplus  linter  codingstyle  alternativeto  artisticstyle 
december 2017 by kme
stl - Iterate keys in a C++ map - Stack Overflow
What's difficult to discern from the STL documentation at, say,, is that the allocator is a std::pair. That gives you the clue that instead of "key" and "value" you need to be saying "it->first" and "it->second" when looping over the elements with a std::iterator.
cplusplus  stl  iterator  map  syntax  solution 
november 2017 by kme
The Lean Mean C++ Option Parser: Main Page
<code class="language-c">
#include <iostream>
#include "optionparser.h"
enum optionIndex { UNKNOWN, HELP, PLUS };
const option::Descriptor usage[] =
{UNKNOWN, 0,"" , "" ,option::Arg::None, "USAGE: example [options]\n\n"
"Options:" },
{HELP, 0,"" , "help",option::Arg::None, " --help \tPrint usage and exit." },
{PLUS, 0,"p", "plus",option::Arg::None, " --plus, -p \tIncrement count." },
{UNKNOWN, 0,"" , "" ,option::Arg::None, "\nExamples:\n"
" example --unknown -- --this_is_no_option\n"
" example -unk --plus -ppp file1 file2\n" },
int main(int argc, char* argv[])
argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present
option::Stats stats(usage, argc, argv);
option::Option options[stats.options_max], buffer[stats.buffer_max];
option::Parser parse(usage, argc, argv, options, buffer);
if (parse.error())
return 1;
if (options[HELP] || argc == 0) {
option::printUsage(std::cout, usage);
return 0;
std::cout << "--plus count: " <<
options[PLUS].count() << "\n";
for (option::Option* opt = options[UNKNOWN]; opt; opt = opt->next())
std::cout << "Unknown option: " << opt->name << "\n";
for (int i = 0; i < parse.nonOptionsCount(); ++i)
std::cout << "Non-option #" << i << ": " << parse.nonOption(i) << "\n";
devel  commandlineargs  parser  cplusplus  c  optionparser  alternativeto  ezoptionparser  getopt 
november 2017 by kme
Why the stack size limit?
The question is, how do you increase the margin? Have your program run ulimit, then re-exec itself? AFAIK, there's no way to change the stack size of a program once it's started, and no way for it to request more stack before it starts. (I suppose you could put "you must have x bytes of stack for this program" in the manual, but then your end users wouldn't read the manual. )

The answer is 'malloc'. But this thread was enough for me to investigate the problem we were having with a program compiling on the cluster but not on our VMs--unlimited stack size on the cluster nodes.
linux  unix  cplusplus  memorymanagement  vmm  devel  solution 
august 2017 by kme
c++ - How do you clear a stringstream variable? - Stack Overflow
For clearing the contents of a stringstream, using:


is correct, although using:

cplusplus  strings  stringstream  solution 
august 2017 by kme
c++ - explicit qualification in declaration - Stack Overflow
You cannot declare (nor define) entities that belong to a namespace outside of their namespace. Do this:

namespace foo { void bar() {} }

not this:

void foo::bar() {} // not legal

EDIT The above is wrong, you can define an entity outside of its namespace, provided its declaration inside the namespace has been seen. There must be some other reason for this error.
cplusplus  compiler  errormessage  solution  devel 
august 2017 by kme
linux - How to install g++ 4.9.2 in Cent OS 6.5? - Super User
CentOS 6/7 official support this. You don't need third party repository. And gcc version is 4.9.2 in CentOS's repo.

yum install centos-release-scl-rh
yum install devtoolset-3-gcc devtoolset-3-gcc-c++

To use the updated tools, start a new shell using the scl command:

scl enable devtoolset-3 bash

More information on the SCL from CentOS and from Red Hat
gcc  cplusplus  compiler  toolchain  c++14  centos  centos6  solution 
february 2017 by kme
bit manipulation - What are bitwise shift (bit-shift) operators and how do they work? - Stack Overflow
As you can see, the digits have shifted to the left by one position, and the last digit on the right is filled with a zero. You might also note that shifting left is equivalent to multiplication by powers of 2. So 6 << 1 is equivalent to 6 * 2, and 6 << 3 is equivalent to 6 * 8. A good optimizing compiler will replace multiplications with shifts when possible.
c  cplusplus  devel  bitshift  math  binary  dammitbrain  solution 
december 2016 by kme
c++ - Why does passing object reference arguments to thread function fails to compile? - Stack Overflow
Threads copy their arguments (think about it, that's The Right Thing). If you want a reference explicitly, you have to wrap it with std::ref (or std::cref for constant references):

std::thread t(foo, std::ref(std::cout));
threads  cplusplus  c++11  multithreading  solution 
december 2016 by kme
C++ singleton vs. global static object - Stack Overflow
I guess you can't just dump a "static" variable in the "private:" section of a class and call it good. It seems to need to be in the initializer.
Actually, in C++ preferred way is local static object.

Printer & thePrinter() {
static Printer printer;
return printer;
cplusplus  static  classvariables  solution 
december 2016 by kme
multithreading - C++ Threads, std::system_error - operation not permitted? - Stack Overflow
You are not linking pthread properly, try below command(note: order matters)

g++ main.cpp -o main.out -pthread -std=c++11
cplusplus  thread  pthreads  compiler  errormessage  solution 
december 2016 by kme
Fastest way to check if a file exist using standard C++/C++11/C? - Stack Overflow
#include <sys/stat.h>
#include <unistd.h>
#include <string>

inline bool exists_test0 (const std::string& name) {
ifstream f(name.c_str());
return f.good();

inline bool exists_test1 (const std::string& name) {
if (FILE *file = fopen(name.c_str(), "r")) {
return true;
} else {
return false;

inline bool exists_test2 (const std::string& name) {
return ( access( name.c_str(), F_OK ) != -1 );

inline bool exists_test3 (const std::string& name) {
struct stat buffer;
return (stat (name.c_str(), &buffer) == 0);
fileio  unix  cplusplus  solution 
december 2016 by kme
glibc - Version `GLIBCXX_3.4.15' not found in CentOS (in file /usr/lib/ - Super User
You can either use 'strings' or 'objdump -x' on the library for this. Try 'ldconfig -p | grep libstdc++' to get the full pathname.
libc  compiler  toolchain  errormessage  cplusplus  solution 
december 2015 by kme
create your own time stamp | c/c++ programming by examples -
void timestamp()
time_t ltime; /* calendar time */
ltime=time(NULL); /* get current cal time */
printf("%s",asctime( localtime(&ltime) ) );
c  cplusplus  dammitbrain  timestamp 
november 2015 by kme
« earlier      
per page:    204080120160

Copy this bookmark:

to read