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

How to avoid that emscripten calls “main” function automatically

I want to generate a WebAssembly from a C-program using Emscripten. I’m using the following flags for emcc: FLAGS = -O0 \ -s ALLOW_MEMORY_GROWTH=1 \ -s TOTAL_MEMORY=134217728 \ -s NO_EXIT_RUNTIME=1 \ -s FORCE_FILESYSTEM=1 \ --memory-init-file 0 \ -s MODULARIZE=1 \ -s WASM=1 \ -s EXPORT_ES6=1 \ -s EXPORTED_FUNCTIONS="['_main']" \ -s EXPORTED_RUNTIME_METHODS=intArrayFromString,allocate,ALLOC_NORMAL \ -DNODEPS=1 That also

Read More
C#

Need to have a working menu but it won't run

I have a previous code similar to this project that has run before. However, now I can’t get this to run. Yahtzee.c #include "Yahtzee.h" int main(void) { int input = 0; do { input = option_choice(options()); } while (input != 3); return 0; } Function.c #include "Yahtzee.h" int options(void) { int options = 0; do

Read More
C#

I am unable to include mosquitto.h to c program on mac

I am trying to use mosquitto.h in my c program. I installed mosquitto with homebrew: brew install mosquitto but when I run: gcc mqtt_subscriber_01.c -o mqtt_subscriber_01 -lmosquitto I get: mqtt_subscriber_01.c:4:10: fatal error: 'mosquitto.h' file not found #include <mosquitto.h> ^~~~~~~~~~~~~ 1 error generated. I create this Makefile: CC = gcc LIBS = -lmosquitto %.o: %.c $(CC)

Read More
C#

problems with C file acces arguments

I’m trying to learn C by making a basic daemon. I’m struggling to understand reading and writing files, since the arguments are correct to most posts and docs. My code is below: #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<stdbool.h> #include<stdint.h> #include<string.h> #include<signal.h> #include <libnotify/notify.h> #define EXIT_SUCCES 0 #define EXIT_FALIURE_READING_FILE 1 #define EXIT_FALIURE_LIBNOTIFY 2 char *ProgramTitle = "styckynotes"; char

Read More
C#

Using global variables after booting from GRUB before setting up the GDT

I’m writing a toy-kernel and the first step would be to set-up the GDT. Obviously I will be using variables on the stack to initialize the GDT; for which, a GDT must already be set up, which is indeed the case as GRUB also sets up a GDT before passing control to the kernel. According

Read More
C#

ESP32TimerInterrupt example doesn't compile for ESP32

I tried to compile TimerInterruptTest.ino example from library ESP32TimerInterrupt. I’m not sure but it looks like that because of library update. But, when I try to compile it throw me this error: In file included from /home/nikola/Arduino/libraries/ESP32TimerInterrupt/src/ESP32TimerInterrupt.h:60, from /tmp/.arduinoIDE-unsaved202491-5718-1ecd3ef.m2hi/TimerInterruptTest/TimerInterruptTest.ino:45: /home/nikola/Arduino/libraries/ESP32TimerInterrupt/src/ESP32TimerInterrupt.hpp: In member function 'bool ESP32TimerInterrupt::setFrequency(const float&, bool (* const&)(void*))': /home/nikola/Arduino/libraries/ESP32TimerInterrupt/src/ESP32TimerInterrupt.hpp:347:23: error: 'TIMER_BASE_CLK' was not declared

Read More
C#

Convention for C ternary conditional operator

Considering the ternary operator ?: in C, I have found 3 common conventions used with it (specifically for variables, as the convention there with the other areas of formatting I assume applies to non-variable assignment uses of the operator). Which one of the valid syntaxes below is standard (the most common/proper convention), and is it

Read More
C#

C and getchar() behaviour

I am pretty new to coding and I read the K&R book. As I try to solve proposed exercises, I face my first problem (1-13). Why with, the code below I get tabul populated while ((c = getchar()) != EOF) { if (c == ' ' || c =='\n' || c == '\t') { ++tabul[lw];

Read More
C#

Is it possible to access a parameter of a function from another function in C?

Is it possible to access the value of a variable from a function within another function. You can assume that the first function is called in the main one. Here is an example: int foo (int x) { int z; // Do things... return 0; } int bar () { // Access value of z

Read More
C#

how to get rid of circular dependencies in C

I’m new to C and I’m stuck on this problem. In C# doing something like this is perfectly ok but in C the compiler works different and it needs to know the type definitions before hand. struct FN; typedef struct { void (*create) (FN *fn); } Window; typedef struct { Window window; } FN; Is

Read More