r/cpp • • Dec 06 '16

zapcc C++ compilation speed against gcc 5.4 and clang 3.9

Thumbnail baptiste-wicht.com
0 Upvotes

r/cpp • • Jun 27 '18

Embed resources in C++ on Windows (Visual Studio)

Thumbnail
mklimenko.github.io
0 Upvotes

r/cpp • • Jun 23 '12

What is the upper limit on for loop iterations?

0 Upvotes

Can anyone explain why a for loop (seen below) runs indefinitely when the the end condition grows past a certain limit? (I'm running on widows vista, in eclipse with MinGw as my compiler)

//This code takes 8 seconds to run for (i = 0; i < 1000000000; i++) // 1x 109 { x++; }

//This code does not stop for (i = 0; i < 10000000000; i++) // 1x 1010 { x++; }


r/cpp • • Aug 09 '08

Is C++ an Elitist Language?

Thumbnail
jintoreedwine.wordpress.com
0 Upvotes

r/cpp • • Jul 14 '14

Oculus Acquires RakNet Middleware & Open-Sources It

Thumbnail
phoronix.com
0 Upvotes

r/cpp • • Feb 04 '15

Compilers - What Every Programmer Should Know About Compiler Optimizations

Thumbnail
msdn.microsoft.com
2 Upvotes

r/cpp • • Aug 26 '19

Why are tutorial videos so long?

0 Upvotes

Recently I had to learn some C++ for a project, and took to my favorite learning resource, youtube.

I've been programming for years, so i'd like to watch a quick video that tells me about the syntax and special cases of c++. But i was shocked that the top results were 4 hour or 9 hour videos teaching c++. Those videos could be great for students, but the content-creators really do waste a lot of time talking about useless stuff.

Maybe my attention span is too short and i've run out of patience, but i learned what i needed about c++ in a few minutes by flying through the 4 hour tutorial.

Are there any youtube channels out there that post fast-pace guides that teach a language in minutes without spending hours talking into a webcam? If not i'd like to start a youtube channel and make that kind of content. i think it'll be fun.

Also is anyone else in the same boat as me that would benefit from videos like that? Is it worth creating?


r/cpp • • Aug 07 '24

Is there a retry / exponential backoff library for cpp?

0 Upvotes

r/cpp • • Mar 17 '22

FinTech: C++, Rust or Others?

0 Upvotes

Hi valued programmers,

I am current charting my learning path and would like to have some valued inputs. I have been reading a little about Rust lately and how it compares to C++ for performance sensitive application developments.

Some background, I am not a professional programmer but a banker. I specialise in the domains of Risk Management and Finance, and currently holds the role of department head. I have a passion for tech in general, from phones to PCs and that includes programming.

As I am moving more into the tech space in banking (such as leading tech projects in the bank), I would like to sharpen my programming skills to enable me to perform better planning for my team / project. I know the pain of projects that are lead or planned by a complete tech noob, and it often leads to frustration and delays in the IT department. I also have a vision of building FinTech application in the future (I have good understanding of the actual requirements of banking), and thus am looking to make my learning more impactful with the limited time I have.

I am looking for a programming language that enables me to build high performance computation 'cores' with the least amount of pain, easy to maintain and stable overtime. The applications that I have in mind are generally non-customer facing applications that needs to interface with large databases (think millions of records with a few hundred fields) to churn results. It does not need to cater for real time results, more often batch processing at end of day is good enough.

Naturally, the language to build the application will need to play well with SQL or NoSQL databases. Ideally, it will also play well with Python as a lot of prototyping, batch scripting, non-performance sensitive modules and even UI will likely be build in Python (given it is very popular in analytics space). Links / libraries with machine learning application such as Neural Network would be an advantage as the application I have in mind will have some ML parts in there.

Personally, I know how databases work, I can write SQL / DDL programming and am able to build a simple database from scratch. I won't consider myself an expert, but I can write reasonably complex queries (with conditions, loops, data manipulation, etc) and some ETLs. I also wrote VBA for Excel before for some automation work, and even built (arguably simple) computation functionality with it that calculates results for a few hundred thousand lines of data in there on a monthly basis. I learnt C a long time ago, have some (basic) understanding of procedural programming and that's about it.

With all the above in mind, what would the opinions of programming gurus here be? As much as I would love to learn more programming languages, my time is rather limited and focus would be key. Apart from this, I am also picking up ML/NN and Python to achieve my end goal.


r/cpp • • Feb 13 '12

C++ program compiled for x64 is slower than complied for x86

Thumbnail c-vision.com.ua
2 Upvotes

r/cpp • • May 25 '21

[Belay the C++] Lambdas as const ref

Thumbnail
belaycpp.com
14 Upvotes

r/cpp • • Aug 03 '24

Why do people use neovim over vscode or a modern ide?

0 Upvotes

what makes neovim more appealing than simply using the neovim plugin in vscode or clion? I feel like nvim takes a lot of config to make it good just so it can behave like vscode


r/cpp • • Aug 27 '12

Why is < faster than <=?

Thumbnail
stackoverflow.com
6 Upvotes

r/cpp • • Apr 07 '21

I am trying to replace CMake with c++

0 Upvotes

I am writing a new build system HMake on top of CMake. Basically, HMake is a C++ library that generates a CMakeLists.txt file. There are very important features missing in it currently. Though I believe they can be added. I was able to generate two trivial CMakeLists.txt files which work for my two projects. One example is the following.

For following c++ code

    executable HMake("HMake", file("main.cpp"));
    for (auto x : fs::directory_iterator("src"))
    {
        HMake.sourceFiles.emplace_back(file(x));
    }
    directory headerDirectory("header");
    //IDD is for includeDirectoryDependency
    IDD headerFolderDependency{headerDirectory, dependencyType::PUBLIC};
    HMake.includeDirectoryDependencies.emplace_back(headerFolderDependency);
    HMake.setRunTimeOutputDirectory(directory("/home/hassan/Projects/HMake"));
    //This is the CMakeLists.txt file
    instructionsFileMain mainFile(HMake, projectDetails(CmakeVersion(), "HMake"));
    std::cout<<mainFile.getScript();

This generates the following CMakeLists.txt file

cmake_minimum_required(VERSION 3.0.0)

project(HMake LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(HMake
        main.cpp
        src/executable.cpp
        src/projectdetails.cpp
        src/file.cpp
        src/sourcefiles.cpp
        src/directory.cpp
        src/instructionsFileMain.cpp
        src/cxx_standard.cpp
        src/cxxStandard.cpp
        src/libraryDependency.cpp
        src/library.cpp
        )

target_include_directories(HMake
        PUBLIC header
        )

set_target_properties(HMake PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY /home/hassan/Projects/HMake)

This is basically the same CMakeLists.txt file that I am using to build the library. Other example is a bit more complex and can be found in my project.

This lacks many important features e.g. I am providing hardcoded paths instead of variables like CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. These and many other missing features I think can be provided using the c++ interface.

Motivation:

This is proof that c++ can be used instead of CMake to specify instructions for build system generators.

Basically, we will embed a c++ compiler in HMake. Then instead of writing the CMakeLists.txt file in CMake language, you will write CMakeLists.txt in c++. Headers related to the build system will be provided by default. Other functions that help in installation or constants or enums that will be used to specify compiler version, c++ version, platform, platform version, architecture, etc will also be provided. This file will then be compiled and executed. At the end of its execution, we will have a data structure that has information that will be used for generating the build system. e.g. in the example above in the last line, we are printing the contents of the CMakeLists.txt file. Instead of this printing of the CMakeLists.txt file we just generate the build system. This is approach 1.

Or we can just embed the C++ parser and then use constexpr vector and string. This way we won't need to embed the compiler backend.

These are long-term goals. Short term goal is to support the most features of CMake in my build system using the optimal c++ interface. So that real-world projects can use my library to generate CMakeLists.txt file by writing c++ code. Once this is done, we can just embed the compiler and eliminate the middle stage of generating the CMakeLists.txt file.


r/cpp • • Mar 12 '15

Linus Torvalds Was (Sorta) Wrong About C++

Thumbnail
news.dice.com
0 Upvotes

r/cpp • • Dec 27 '23

catch2 is bad?

0 Upvotes

Hello friends,

if been using catch2 for some time now and i have to say i'm very disappointed with it, my two major problems are:

  1. cant break into gdb when an unexpected exceptions is thrown (this alone should be a deal breaker for anyone?) (https://github.com/catchorg/Catch2/issues/1030)

  2. stepping into the actual function call when its wrapped in a REQUIRES(..) first goes to 5 internal catch function calls.

these two things alone make debugging a nightmare, so my question to you is:

is there another testing framework that doesn't suffer from these problems or is there anyway i can get rid of these two problems? Thank you for your suggestions.

​


r/cpp • • Jun 11 '26

A Codex Experience Report

Thumbnail
youtube.com
1 Upvotes

AI this, AI that, it seems it's all anyone can talk about these days. But is it any good? Curmudgeons say that the generated code is garbage and that "AI can't do it". Are they right? The hype train has left the station and is saying engineers are going to be unemployed in the next 18 months. Are they right?

This month, Richard Thomson will give us an experience report on using Codex for improvements he's been making to his open source fractal renderer, Iterated Dynamics and the associated projects Formula Compiler, ParAnimator and par-beatdown.

Is it the end of the world or is the future so bright I gotta wear shades?


r/cpp • • Aug 03 '15

Open standards — if you attend our meeting in Hawaii; Impressions of a C++ working group

Thumbnail
denisbider.blogspot.com
1 Upvotes

r/cpp • • Nov 04 '15

I wrote a std::function like object the size of a void*

1 Upvotes

[edit] Yes, the title is wrong, it's the size of a void* + a function pointer. In VC++ 2013 std::function is 24 in x86 and 32 bytes in x64. This wasn't meant to be a superior replacement to std::function, I just wanted one that was as efficient as writing a standalone function that has it's own data (the void* part).

[edit2] As pointed out below, it's not perfect, I should have said 'feedback wanted' at the top.

[edit3] I was able to remove const_cast and the other consts. It turns out my constructor was being used for all copies, so I added a non const copy constructor. If it takes const, the template is a better match for non const values passed in and that's not good. I'm not sure if I need both the const and non const default constructors.

I deal with callbacks often enough in code to want to make them more elegant. For anyone who's used std::function you already know what I mean! In my case I wanted a std::function that was the size of a void* so that I could use the same class to hook up to external APIs that take a function pointer and a void*.

Most of the class is pretty standard but I feel these two lines are pretty evil:

m_pData=*reinterpret_cast<void**>(&v);
m_pCallback=[](void *pData, Params&&... params) -> return_type { return (reinterpret_cast<T &>(pData))(std::forward<Params>(params)...); };

I basically take the lambda passed in and store it's data in a void*, then create a function pointer that takes the void* and turns it back into the lambda call.

I mostly use it for holding [this] capture lambdas, since those are always a single pointer.

Is there a better way? I can imagine it being possible to create a lambda with data that needs to be properly copy constructed instead of just a memory copy, but I got lost trying to figure out how the STL implements it.

  // Simple Callback that can take a lambda with a single pointer capture
  // For example: Set([this]() { Do stuff with this pointer; });
  template<typename Callback>
  struct TCallback;

  template<class return_type, typename... Params>
  struct TCallback<return_type(Params...)>
  {
     typedef return_type (*Callback)(void *, Params&&...);

     TCallback() = default;
     TCallback(TCallback&) = default; // Added to fix const issue
     template<class T> TCallback(T &v) throw() { Set(v); }

     template<class T> void Set(T &v) throw()
     {
        static_assert(sizeof(T)==sizeof(m_pData), "Can't hold arbitrary sized functor, only able to hold a single pointer sized one");
        m_pData=*reinterpret_cast<void**>(&v);
        m_pCallback=[](void *pData, Params&&... params) -> return_type { return (reinterpret_cast<T &>(pData))(std::forward<Params>(params)...); };
     }

     void Reset() throw() { m_pCallback=nullptr; }

     operator bool() const throw() { return m_pCallback!=nullptr; }
     return_type operator()(Params... params) { return m_pCallback(m_pData, std::forward<Params>(params)...); }

  private:
     Callback m_pCallback{};
     void *m_pData{};
  };

Removed these from the class as they weren't really relevant to the question and just added complexity:

// Used to pack into a window message
Callback GetCallback() const { return m_pCallback; }
void *GetData() const { return m_pData; }

// Used to reconstruct from a window message
void Set(Callback pCallback, void *pData) throw() { m_pCallback=pCallback; m_pData=pData; }

r/cpp • • Feb 03 '19

A criticism of std::embed (D1040)

Thumbnail stonecode.ca
1 Upvotes

r/cpp • • Dec 02 '21

Which is/are the current best framework/s for C++ to create GUIs?

0 Upvotes

I was planning on starting to design GUIs with C++, and I though on using Qt, but I saw that it isn't open source any more and that I might run into some trouble. For that reason, I would like to ask which is the best framework available right now (both multiplatform or only Linux) that I could start learning? Also, is the reason why I decided not to use Qt good enough, or it would actually be a good try?


r/cpp • • Aug 25 '14

An overview of data serialization techniques in C++

Thumbnail
rubentorresbonet.wordpress.com
1 Upvotes

r/cpp • • Sep 08 '14

Hi C++ pros, I need your help for a minute. Is it possible to do this lambda event manager in C++?

Thumbnail
stackoverflow.com
1 Upvotes

r/cpp • • May 13 '18

The Most Beautiful Piece of Code That Prints 42 (Towel Day :)

Thumbnail
fluentcpp.com
1 Upvotes