October 22, 2024
Chicago 12, Melborne City, USA
C#

How to set launch target in VSCode with a makefile?

I’m new to makefiles and was trying to get it working with vscode but I’m not sure how to set the launch target? From what I understand when I press F5 vscode will start at the "all" rule in the makefile and then go to build and main which will build the main.exe? In vscode

Read More
C#

How can I see the console output in Compiler Explorer (Godbolt)?

If I compile a piece of code that writes to the console I can’t see anything, only the assembly code on the right. Link. How I can I see what’s printed from a call to std::cout? You need to sign in to view this answers

Read More
C#

Why does my recursive strlen function return value 4 times bigger?

I’m trying to implement a strlen function in C with recursion and for some reason it’s returning a 4 times bigger value than expected. int *strlen(char *s) { if(*s == '\0') return 0; else return 1 + strlen(s+1); } Interestingly, when I change the type return of the function to "char", I get the desired

Read More
C#

How to keep compile times down in C

If I structure my C program like this will it keep the compile times down as the project grows? #include <stdio.h> #include "lib/manager/manager.h" #include "lib/loop/loop.h" #include "lib/utility/utility.h" int main() { FN fn; dev_loop_init(&fn); dev_utility_init(&fn); fn.util.log("test"); return 0; } A manager.h header file which I will include in every "module". #ifndef DEV_MANAGER #define DEV_MANAGER typedef struct

Read More
C#

Esp32 execute AT command from User-defined AT Command

How can I execute other AT command from User-defined AT Command? For example at_custom_cmd.c: static uint8_t at_test_cmd_test(uint8_t *cmd_name) { uint8_t buffer[64] = {0}; snprintf((char *)buffer, 64, "test command: <AT%s=?> is executed\r\n", cmd_name); esp_at_port_write_data(buffer, strlen((char *)buffer)); EXEC("AT+HTTPCGET="http://www.my.com"); // <-- How can I do it? return ESP_AT_RESULT_CODE_OK; } I tried to search exec command in offical site,

Read More
C#

Video game “manager” class in C

I am new to C and I am wanting to make a video game. I was wondering what you all thought of this structure. My goal is to be able to easily access functions and data from a single struct. This way I only need to include one file everywhere. #include <stdio.h> #include "lib/manager/manager.h" #include

Read More
C#

A Windows-compatible C IDE that will be able to compile FFmpeg?

I want to set up an environment on my PC (Win7x64) that I will be able to combine these projects and compile them into one executable: FFmpeg AMV codec tools For this I need an environment that can compile/debug both the above projects (creating a Windows compatible exe). Any ideas? You need to sign in

Read More
C#

Questions about the GCC compiler and linker

Say your program is composed of two source files (main.c and auxiliary.c) and two header files (declarations.h and auxiliary.h). Then you run the compiler as follows: $gcc main.c auxiliary.c -o myprogram Question 1: Will the compiler create one single object file for my program (i.e., just the libraries are missing) or will it create two

Read More
C#

Real world project structure with .C and .H

So when we make a C program we just need one .C file right? We can include additional C files and H files to our main .C file but I’m not sure what the difference between them is. Why would one create multiple .C files? Couldn’t they just create a bunch of .H files and

Read More
C#

minimum write size with O_DIRECT

I am writing a custom database engine for Linux 2.6.X kernels in C and I need to know what is the minimum write size of a write() system call for a file opened with O_DIRECT flag? In the docs it says that since linux 2.6 kernel versions you can use 512 byte block. But, what

Read More