« first day (3709 days earlier)      last day (606 days later) » 

00:00
Does anyone know how I might transport function pointers through shared library boundaries?
(C++)
REFRESH! There are 7272 unanswered questions (90.5716 answered)
00:38
@FreezePhoenix There is no way to guarantee the memory address will be the same on both sides.
It is a good way to cause a SEGV or buss error.
01:06
@pacmaninbw Wdym?
 
2 hours later…
03:06
@FreezePhoenix There is no guarantee that the shared library is operating in the same memory space as the original program, it may be in a different thread or process and that means that the memory locations will be different.
03:35
you could use addPolygons, but this seems to work okay. Maybe something for gis.stackexchange.com or codereview.stackexchange.com maybe? — Mark 40 secs ago
If you are looking for a review of working code you might want to look at codereview.stackexchange.com In order to be on-topic here you need to focus on one problem and explain what the code is supposed to do and what is not working. — Retired Ninja 15 secs ago
04:07
Monking
 
3 hours later…
06:44
Monking
07:00
0
Q: Visual Studio 22 generates C4834 nodiscard warning even when the function does not have [[nodiscard]] attribute

HimanshumanI have this code which I am trying to compile in visual studio 22. bool getIDFromInputParam(string strParam, string &strInputFolder) { strInputFolder = ""; size_t keyLoc = strParam.find(WINDOWS_DELIMITER_STR "**" WINDOWS_DELIMITER_STR "*"); if(keyLoc != string::npos) strParam....

07:16
Stack Overflow is generally about asking why code doesn't work, for code which does work, but could you improvements, consider codereview.stackexchange.com instead. — Matthieu M. 6 secs ago
 
2 hours later…
09:32
0
Q: Change unit-test structure to avoid try/except/finally clause

MathieuI have 10 or 20 tests with the same structure which I would like to improve. The test itself is nested within a try/except/finally clause to make sure that some of the variables are deleted at the end. def test_time_correction(): """Test time_correction method.""" sinfo = StreamInfo("test",

0
Q: A parallel MSD radix sort in Java for integer keys

coderoddeI have this repository: https://github.com/coderodde/ParallelRadixSort.java/tree/main It contains a parallel MSD radix sort presented below: package com.github.coderodde.util; import java.util.ArrayList; import java.util.List; import java.util.Random; /** * This class provides the method for p...

 
2 hours later…
11:39
0
Q: Output a Python dictionary as a table with a custom format

David GardI have a Python directory containing some str: int key-value pairs, and my goal is to display that data in a tabular format. I am unable to use the tabulate module because it seems that it cannot display data exactly as is required by the project sponsors (and as far as I know you cannot customis...

 
3 hours later…
14:49
If you are looking for a code review, there's a [separate site](codereview.stackexchange.com). If you have specific questions about how coroutines work, those can be asked here. — Jorn 5 secs ago
15:14
Monking
15:25
@pacmaninbw No the shared library pointer that I am trying to pass is being accessed with dlsym
well
0
Q: Immutability and side effect

fluminisTo give a little context, I try to do one more time the Emilybache lift kata. This time I try to work with immutable objects. I start with a Lift as a java record. So every time the world evolved (simulate that the time pass), a new Lift is produced. So far so good. But there are some external va...

not quite
The main program is loading an init symbol from a .so, and passing it a
template<typename ARGUMENTS, typename RETURN = void>
class ServiceInfo {
	public:

		typedef RETURN (*HANDLER)(const ARGUMENTS&);
		HANDLER child_handler = nullptr;
		GameData* G;
		std::function<void()> destructor;
		~ServiceInfo() {
			if (destructor != nullptr) {
				destructor();
			}
		}
};
The .so accepts it like this:
ServiceInfo<PathfindArguments, PathfindArguments::MapPathResult>::HANDLER init(ServiceInfo<PathfindArguments, PathfindArguments::MapPathResult>* info) {
	info->destructor = cleanup;
	GameData* data = info->G;
	pather = std::unique_ptr<Pather>(new Pather(data));
	return ipc_handler;
}
Where
PathfindArguments::MapPathResult ipc_handler(const PathfindArguments& args) {
	if (args.start_map != args.end_map) {
		pather->mLogger->info("Cross-map pathfinding not supported ({} -> {})", args.start_map, args.end_map);
		return { PathfindArguments::MapPathResult::FAIL };
	} else {
		if (pather->map_to_id.contains(args.start_map)) {

			unsigned int map_id = pather->map_to_id[args.start_map];
			return pather->maps[map_id].path(args.start, args.end);
		}
		return { PathfindArguments::MapPathResult::FAIL };
Well, hm....
I could try and implement some form of type erasure
Using a wrapper of std::any
15:54
16:30
It's not really clear where the problem is, and, sincerely, the fact that you didn't take your time to improve the function doesn't really help us: StackOverflow is not a debugging or code review service. In any case, if you're trying to use threading to access the UI or even create UI elements, that's not an option: widgets are not thread safe, and can only be created in the thread of the QApplication. — musicamante 23 secs ago
Monking
0
Q: remote script execution

Kittoes0124I have a series of scripts that I need to run in a DevOps environment; certain routines cannot be executed directly within a session and yet still need to be supported. The following script is what I've come up with after much trial and error. It seems to do exactly what I need but I am curious i...

16:57
@IvanSmirnov Cool! I'm on codereview too, so just tag me there. — Ted Lyngmo 54 secs ago
17:34
0
Q: Is there a more concise way to write this Procedure

JeffersonI have this stored Procedure that is passed in the data below that will building the SQL select that will get EXEC. The data that can be passed in can me null so I have three IF ISNULL checking and then adding to the @SqlWhereCommand object. Any help would be great. parameter @StartDate AS DATE =...

17:59
0
Q: Thread safety when using coroutines in Kotlin

mtfujiI have been reading alot about Thread safety recently and I am wondering if I have done anything wrong in my code base. I need a peer review to help me identify if my code base is Thread safe or not. When should I use the synchronized block to ensure Thread safety? In what circumstances do I have...

0
Q: Implementing default value for HashMap

user21476047I want to store a default value to my HashMap whenever a call to my MAP constant does not have a value associated with the key that is passed. This is what I have implemented: public class Constants { public static final Map<String, String> MAP = DefaultHashMap.initMap(); private static...

 
1 hour later…
19:16
@Phroggie from my recollection those were only marginally helpful
I remember when I did that disaster with the python-version tag merger setup and relied on the mod-only help pages around that ... didn't go all that well
I did not know that C++ let you do cursed things like this:
template<template<typename... Args> typename T>
struct erased_type {
    private:
        std::any internal;
    public:
        erased_type(): internal() {}
        template<typename... Args>
        erased_type(const T<Args...>& obj): internal(obj) {}
        template<typename... Args>
        erased_type(T<Args...>&& obj): internal(obj) {}
        template<typename... Args>
        erased_type& operator=(const T<Args...>& obj) {
            internal = obj;
            return *this;
        }
oh dear god why would you need such an abomination?
@Vogel612 Yeah from what I've seen the mod docs are far worse than the non-mod ones. I can imagine "why are you reading docs, just go on meta meta" was a common thought pattern.
@Vogel612 To avoid casting function pointers unsafely
Also "do not share anything inside the mod only docs" and everything is on meta meta anyway...
19:20
@Phroggie that's one and the other one is asking in TL, because institutional knowledge was strong and CMs knew everything that there was to know about the tools and they were available
and when they no longer were accessible to every mod quickly, there were more important issues than mediocre mod help center docs
@FreezePhoenix but why would you need move and assignment semantics over the same internal structure? that sounds like you messed up some dereferencing somewhere
@Vogel612 Yeah sounds about right. I guess better docs will come in 6-8 weeks
@Vogel612 So you can just assign values to it... like std::any lets you do.
@FreezePhoenix I still don't understand why you'd want to knock out the compiler
Wdym knock out
at least some of its features are used to help you do things in a safe way
19:24
Well yeah but the compiler also just goes "Mmm yess casting a void function pointer to a non-void function pointer, yes, this is a good idea"
You're right. I write a multithreaded version of the program and it is just as fast as the fread() version! See: codereview.stackexchange.com/questions/285844/…1f604 19 secs ago
I fail to see how what you proposed there is an improvement over that?
Because here you can't just do that
Take into consideration the following code:
#include <iostream>

void somethin() {
    return;
}

int main() {
    int a = 1;
    void(*A)() = somethin;

    int(*B)() = (int(*)()) A;

    std::cout << B() << std::endl;
}
This emits zero warnings
@Vogel612 Whenever you want to use some arcane piece of mod tooling, you're usually best of asking an SO mod.
They have so much more throughput that they touch most of the tooling a lot more than we do.
Even this emits zero warnings:
#include <iostream>

long somethin() {
    return 1;
}

using A = long(*)();
using B = double(*)();

int main() {
    A a = &somethin;

    B b = (B) a;

    std::cout << b() << std::endl;
}
19:30
@Mast-onstrike yea, they use every tool in that box a lot more often
But if you use the erased_type...
long somethin() {
    return 1;
}

int main() {
    erased_type<std::function> temp = std::function(somethin);

    auto a = temp.get<long()>();
    std::cout << a() << std::endl; // prints out 1

    auto b = temp.get<double()>();  // throws std::bad_any_cast

    std::cout << b() << std::endl;
}
Thus, type safety.
@FreezePhoenix This is all very interesting but I don't have time to help you out, especially with pseudo code.
Asking how to questions belongs on SO.
At this point, I wasn't asking how, just remarking on the fact that I didn't know C++ let you do template<template<typename... Args> typename T>
0
Q: Can my multithreaded O_DIRECT file read-and-process program be faster?

1f604Here is my code. It reads a file and returns the sum of all the bytes in the file: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <malloc.h> #include <iostream> #include <chrono> #include <thread> #include <mutex> #include <condition_variable> #define BUFS...

20:08
This code doesn't seem to run. There an extra k flowing around in the code and bigRotate is not defined in the code or in the included libraries. You can try the test cases included with the proposal: stackoverflow.com/a/1640205/2372064. But this really isn't a specific programming question. If you are looking for a code review, there's a separate site for that: codereview.stackexchange.comMrFlick 38 secs ago
20:26
Meanwhile on MetaSE:
I’m voting to close this question because it's dumb. — CDR 1 hour ago
0
Q: Protein databank file chain, segment and residue number modifier

JamesTMy first non-trivial bash script after fully moving to Linux Mint last week is attached (modify_cccp_bundles.in). The script performs on protein databank (PDB) files that have been generated using an online CCCP (Coiled-coil Crick Parameterization) server. To use the generated PDB files for my ow...

20:53
@SᴀᴍOnᴇᴌᴀ deleted
 
2 hours later…
22:29
As interesting as code review questions are, they are off-topic on Stack Overflow. Consider posting it on the Code Review website after reading their on-topic guidance. — halfer 40 secs ago
 
1 hour later…
23:38
I'd suggest that your question "is this the most elegant..." is still opinion based. The second part of it ("is there a more powerful way of doing this") may be a good fit for codereview.stackexchange.comjnpdx 37 secs ago
23:55
0
Q: Entity Component System Using C++

Andrei RostIntroduction I'm a novice C++ programmer currently working on a low-level game engine using C++, OpenGL, and GLFW. I've implemented an Event System and an Input Manager, which you can check out here: Improved Event System & InputManager Using C++. Graph For clarity, I've included a graph: Compon...

0
Q: Is tag dispatch as used in CppCoreGuidelines T.65 antiquated?

Jan SchultkeThe CppCoreGuidelines contain the following: T.65: Use tag dispatch to provide alternative implementations of a function [...] Example struct pod_tag {}; struct non_pod_tag {}; template<class T> struct copy_trait { using tag = non_pod_tag; }; template<> struct copy_trait<int> { using tag = pod...


« first day (3709 days earlier)      last day (606 days later) »