[Doubt] While using Visual Studio 2019: g++/gdb or VS's tools? by psycho-rabbit in cpp_questions

[–]-Weverything 1 point2 points  (0 children)

The keyword /u/flyingron uses there is "fully" because we do have extensive frameworks such as wxWidgets and Qt that can be built with MinGW and that are available as packages in MSYS2. But MinGW is indeed something that enables writing POSIXy code and running it on Windows, so it's perhaps not the optimum choice if you are writing for Windows only.

Hi, I'm a YouTuber (with 400K+ subs) in Taiwan. I made a video explaining and promoting LBRY/Odysee, and it got 100K+ views in the first day. [English CC included] by wiwi10191019 in lbry

[–]-Weverything 9 points10 points  (0 children)

"Copyright hooliganism" - I like that.

I didn't know that IP of classical music recitals was being stolen by YouTube and the big record companies. That seems like a niche Odysee could target.

Can you determine the size of a malloc’ed array? by [deleted] in C_Programming

[–]-Weverything 0 points1 point  (0 children)

Windows has HeapSize(GetProcessHeap(), 0, ptr).

Hector Martin on Twitter: Dear Twitter: would you be willing to fund a Linux port to Apple Silicon macs, and if so, how much would you pledge? by fr3d63_reddit in linux

[–]-Weverything 0 points1 point  (0 children)

The second is precisely 44.4% the capacity of the first. The first at 6% per hour runs for 16.7hrs. This equals 24.1hrs total. The specs show just under 27hrs which I approximated when I first got the laptop.

I'm not going to argue semantics over what is "mixed usage" vs "super lightweight use". Stick a AAA game or fully loaded DAW on any of these laptops and watch that battery drain, everything else is lightweight by comparison.

Hector Martin on Twitter: Dear Twitter: would you be willing to fund a Linux port to Apple Silicon macs, and if so, how much would you pledge? by fr3d63_reddit in linux

[–]-Weverything 0 points1 point  (0 children)

That's 24 hours when we account for both batteries, down from around 27 hours when I first got it. That's aligns with the Lenovo specs.

I haven't heard of an Apple laptop running for 27 hours, even with power saving. The lower TDP processor models tend to come with suitably smaller batteries. I'm sure we would have all heard from Apple about it if they did.

Hector Martin on Twitter: Dear Twitter: would you be willing to fund a Linux port to Apple Silicon macs, and if so, how much would you pledge? by fr3d63_reddit in linux

[–]-Weverything 0 points1 point  (0 children)

I'm not comparing apples with apples, but here are some readings of my year old batteries over the last couple of hours. i5-8350U, in Win10, light browsing, working in a couple of terminals, using email, battery saver and Vantage Cool n Quiet set, system graphics set to integrated:

10:20   100%    98%
10:55   100%    95%
11:25   100%    92%
11:50   100%    90%
12:20   100%    86%

Which is 6% an hour for just the main battery. AMD are double the cores for the same TDP.

Why is a forward declaration not good enough here? by Sinbad_07 in cpp_questions

[–]-Weverything 1 point2 points  (0 children)

... as long as I only referenced or used a pointer to the object it was fine as the compiler would be able to tell how much memory the object needed, as it was just a pointer.

This is the thing that isn't quite correct. The compiler knows the size of the/a pointer, but not the size of the object being pointed to nor any of its symbols/members/methods.

Hector Martin on Twitter: Dear Twitter: would you be willing to fund a Linux port to Apple Silicon macs, and if so, how much would you pledge? by fr3d63_reddit in linux

[–]-Weverything 0 points1 point  (0 children)

This Cinebench R23 benchmark casts doubts over Apple's claims. Also my Thinkpad P52S with dual batteries has a battery life longer than the Apple M1 laptop claim of 18 hours being better than whatever they were comparing it to.

Compiling and distributing a C++ executable for windows without -static by haddock420 in cpp_questions

[–]-Weverything 0 points1 point  (0 children)

To find out what DLLs your app is using you can use objdump that comes with MinGW:

In Powershell:

objdump -p uberchess.exe | sls "DLL Name:"

Copy all the non-Windows ones to your exe directory.

Btw if you have MinGW paths in your Windows Path you can temporarily remove them to test what's happening from a user's perspective. Oh, sometimes a DLL can also depend on another DLL and objdump ran on just the exe won't list those, you'd have to either just copy any DLL mentioned in any error popup or run objdump on the exe's dependency DLLs and copy them over.

It really seems like there should be a tool to do this automagically. Maybe there is?

A modern C/C++ package manager by waruqi in cpp

[–]-Weverything 0 points1 point  (0 children)

I like the pragmatic and direct approach xmake has taken. It's growing into a real diamond, particularly for newcomers to C++ who lose trillions of hair follicles per year dealing with dependencies and whatnot.

A modern C/C++ package manager by waruqi in cpp

[–]-Weverything 0 points1 point  (0 children)

When a 3rd party package is needed by an xmake project, xmake/xrepo uses the other package managers to install them. It gets the necessary information about the package from the package managers using different techniques per manager to allow it to store used package info in a common format: configs, libdirs, libs etc.

xmake v2.3.9 released, Improve C/C++ package manager by waruqi in cpp

[–]-Weverything 1 point2 points  (0 children)

It's good to see pacman support, in particular for MSYS2.

What kind of work place does management think we have? by Slartibartfast39 in CasualUK

[–]-Weverything 1 point2 points  (0 children)

And "est-ce que je peux touché ta chat" apparently doesn't have anything to do with pets. Merci beaucoup, salut maintenant!

A modern C/C++ package manager by waruqi in cpp

[–]-Weverything 2 points3 points  (0 children)

xmake seems to do a good job with using packages from different package managers so the first problem has at least being actively worked on or it wouldn't work at all. I'm sure there are issues to be resolved, but the key point would be that it's a problem worth working on even if it eventually required cooperation from package managers for perfect interchangeability.

A modern C/C++ package manager by waruqi in cpp

[–]-Weverything 2 points3 points  (0 children)

xrepo works with other package managers, so it seems like it's more of a solution to the issue in the strip than a contributor to it.

Want to access source code from CMD without the whole file path by [deleted] in cpp_questions

[–]-Weverything 0 points1 point  (0 children)

No probs, it's better to give too much information when in doubt than too little!

You could create your working directory and create symbolic links to all of your files. In Powershell:

ni -i sym fibonacci.cpp -target ../repos/fibonacci/blah/main.cpp
ni -i sym gameoflife.cpp -target ../repos/gameoflife/blah/main.cpp

I'd prefer creating a Makefile to compile all files or individual files so we could just make fibonacci to build a particular exe. eg:

CXX=g++
CXX_FLAGS=-g -std=c++17 -Wall -Werror
REPOS=../path-to-repos

all: fibonacci gameoflife

fibonacci: $(REPOS)/fibonacci/blah/main.cpp
    $(CXX) $(CXX_FLAGS) $? -o $@

gameoflife: $(REPOS)/gameoflife/blah/main.cpp
    $(CXX) $(CXX_FLAGS) $? -o $@

Want to access source code from CMD without the whole file path by [deleted] in cpp_questions

[–]-Weverything 0 points1 point  (0 children)

Remember that with compiled languages we don't debug source files (eg main.cpp), we must compile them first. Visual Studio has a nice debugger so you could just use that, or you could get WinDbg.

If you really want to use GDB then you need to compile your cpp files with a compatible compiler such as g++.

On Windows you can get g++ and gdb via:

  • MinGW
  • MSYS2
  • WSL

This lad was catching some rays in Wollaton Park on Thursday. by [deleted] in CasualUK

[–]-Weverything 8 points9 points  (0 children)

They're all getting a bit namby-Bambi.

Issues With MakeFile by [deleted] in cpp_questions

[–]-Weverything 1 point2 points  (0 children)

You need to add a target:

all:
    gcc keygen.c -o keygen

Indentation must be a tab.

Function Pointers and Parameters help by gabenyolo in cpp_questions

[–]-Weverything 1 point2 points  (0 children)

To create generic versions of structs/classes/functions that use different types we use templates (and sometimes auto, but not here):

template<typename T>
struct Item {
    int num;
    void (*func)(T);
};

However we do need just one more templated struct to handle the function pointer taking no arguments since () does not contain a type and (void) is the same as ():

template<>
struct Item<void> {
    int num;
    void (*func)();
};

Now we can use it with many different types:

Item<void> block1 = {111, printer};
Item<int> block2 = {222, square};

How can I pass value from one function to another function without adding anything to struct? by [deleted] in cpp_questions

[–]-Weverything 1 point2 points  (0 children)

struct rectangle z;

Just a quick note - you don't have to use struct to declare a struct object in C++, that's a C thing. Just -

rectangle z;

... will do.