October 22, 2024
Chicago 12, Melborne City, USA

C++

C++ is a general-purpose programming language. Use this tag for questions about/utilizing C++. Do not also tag questions with [c] unless

C++

How to force gcc to do printf checks on non-literal format strings?

const char* const non_literal_string = "Hello %d"; void my_print() { /* * I would like GCC to throw a warning when compiling this line because the * argument is not of int type. */ printf(non_literal_string, "World!"); //Like it does here printf("Hello %d", "World!"); } Above I have declared non_literal_string as const char* const so neither

Read More
C++

Why does my variadic macro throw an error when nothing is passed?

Here’s a more structured and formatted version of your question for Stack Overflow. I’ve included necessary details and explanations according to their question guidelines: Title: Why does my variadic macro throw an error when nothing is passed? Body: I’m trying to create a C program that takes multiple integers as input via the print(...) macro,

Read More
C++

Raycaster is not mirroring textures on the y-axis

I am recreating 3Dsage’s raycast engine but I cannot seem to properly mirror the north and south wall textures along the y-axis. The arrow placed in the top left of the texture should continue in its direction but it seems to flip on walls facing the opposite direction? here is my source code: //STOPPPED VIDEO

Read More
C++

How to move around in the console using the arrow keys, c and win32

I am working a text editor in the C prigramming language and I am stuck on how to make the user be able to move around in the console using the arrow key here is my code if you can help that would be great thank you. // EDIT LOOP void insertMode(char *buffer, const char

Read More
C++

Bitmapped file data displays incorrectly

I have a BMP image file of the moon graphic from the original Space Invaders arcade game. I’m displaying this on a 240×320 TFT display using a RPi Pico. I can’t get it to display correctly, so I’m wondering if I pulled the data from the file incorrectly, or if it’s something else. This is

Read More
C++

How to get the physical address of a file in RAM?

I have found a couple of related posts: https://unix.stackexchange.com/questions/279729/how-to-see-information-inside-inode-data-structure https://unix.stackexchange.com/questions/581323/is-it-possible-to-find-the-physical-address-of-a-file-in-disk But nothing quite answers my question. I have a process which continuously reads a file and I would like to get the physical address of the file it is continuously reading. I know which file it is reading. The process in question does not use

Read More
C++

Xcode problem while executing C OpenMPI project

On an M3 Pro, in Xcode, I want to run a simple C source file: #include <mpi.h> #include <stdio.h> int main(int argc, char** argv) { MPI_Init(&argc, &argv); int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); printf("hello from process %d of %d total processes\n", world_rank, world_size); MPI_Finalize(); return 0; } It successfully builds, but it doesn’t

Read More
C++

What are your effective methods to find relevant docs for C, not C++?

To get a few obvious things out of the way: I am aware that C++ and C do not have official docs due to how the standard ISO specifications are written, etc. However, I am wondering how gcc/C developers (specifically non-C++ devs) find docs for their C specification/compiler, without pollution of information relating to C++

Read More
C++

Macro that expands to value or empty, based on boolean argument

I’m generating some compile-time code. I need to append a suffix to a generated function name, based on a macro boolean. The suffix is either present or empty. How to do that? #define FUNC_NAME(name, hasSuffix) name ## MAYBE_SHOW_SUFFIX(hasSuffix) FUNC_NAME(foo, true); // would generate: foo_ FUNC_NAME(foo, false); // would generate: foo You need to sign in

Read More
C++

Since when have the notifications registered by LdrRegisterDllNotification() started to work differently?

The Microsoft’s documentation about the function LdrRegisterDllNotification() states that DLL load notifications registered by this function: Registers for notification when a DLL is first loaded. This notification occurs before dynamic linking takes place. I wrote the following test program to test this assertion and while these notifications act according to the documentation in Windows 7

Read More