Skip to main content
Filter by
Sorted by
Tagged with
5 votes
2 answers
134 views

I have a simple struct in C and I used typedef to create an alias (db) for it: typedef struct { char* name; } db; I then allocated memory on the heap for a pointer: db *a = malloc(sizeof(db)); a-&...
Mahdi Hosseini's user avatar
0 votes
1 answer
134 views

Im trying to make a language for a book library, and want to achieve this syntax. CREATE BOOK { NAME: "b1", AUTHOR: "me", } How can I use cpp and macros so when this is ...
daskalos's user avatar
Best practices
0 votes
5 replies
88 views

Let's take a silly example: #define MAX_NUM_BITES 20 ... void live_another_day() { ... int num_bites = 0; ... eat_little_pig(&num_bites); if (num_bites>MAX_NUM_BITES) { printf(&...
Lolo's user avatar
  • 4,219
1 vote
1 answer
121 views

While upgrading twig v1.30 to v3.22.0 i encountered some problem using macros from an external file and calling them by using a variable value as dynamic name. Given the twig file with the macros: {# ...
Olli's user avatar
  • 1,764
Advice
0 votes
7 replies
160 views

So I've been using this code for generating such statements following This Reddit post: #define LOOP(seq) END(A seq) #define BODY(x) int x; #define A(x) BODY(x) B #define B(x) BODY(x) A #define A_END #...
Doofus's user avatar
  • 3
5 votes
1 answer
173 views

The same code, one generated by macros and the other handwritten, produces different results.I'm lost and don't know how to fix it. my environment is follow: vs2019, msvc2019_64, c++14 if using ...
user31892351's user avatar
2 votes
1 answer
121 views

I wrote my "Result" macro header, using C23 and some of the newest features: #pragma once #include <stdio.h> #include <stdlib.h> #define __RESULT_EAT_PARENS(...) __VA_ARGS__ ...
Karesis's user avatar
  • 23
2 votes
1 answer
110 views

I have the below code I want to print Use skeleton! if SKELETON_ENABLED is defined and is not running on MAC OS, and Don't use skeleton!\n otherwise. The program prints Don't use skeleton!\n, even ...
User's user avatar
  • 25
1 vote
1 answer
80 views

I wonder whether it is possible to call define-syntax-rule in a loop-like construction like for-each. I explicitly say 'loop-like' because I know that normal Scheme evaluation comes after macro ...
lemzwerg's user avatar
  • 852
2 votes
1 answer
113 views

I am using MPLAB X IDE version 5.43 to develop an embedded project for a PIC18F8722 microcontroller. It has a timer TMR0 which can be configured to be 32 bits. I had lots of statements: TMR0L = 0; ...
Guille's user avatar
  • 472
5 votes
2 answers
168 views

I want to create a macro that impements a trait A for a type if it implements a trait B. The macro I implement will be given a list of types (String, i32, ...). Then for each argument I want to ...
Xiao_e_yun's user avatar
0 votes
0 answers
46 views

I make my drawings in Krita while I write my report in TexStudio. In Krita I select part of the drawing and put it on the clipboard. I put my cursor in the .tex file at the desired position and run ...
noste99's user avatar
  • 385
1 vote
1 answer
67 views

I have a pretty simple ENUM macro in MASM32 that uses VARARGs to assign incrementing values to symbols: ENUM MACRO vargs:VARARG LOCAL num_ num_=0 FOR varg,<vargs> varg EQU ...
GreatCorn's user avatar
  • 111
2 votes
3 answers
245 views

When compiling my program using a recent version of OpenVDB library by Clang in C++20 mode, I get the error: error: use of the 'assume' attribute is a C++23 extension I see that it is due to the ...
Fedor's user avatar
  • 24.8k
0 votes
1 answer
118 views

I'm trying to implement a Rust procedural macro that exports a C-compatible function for a driver I'm writing. Here's my macro: extern crate proc_macro; use proc_macro::TokenStream; use quote::quote; ...
Juraj's user avatar
  • 1
0 votes
1 answer
62 views

Shadow-cljs has a resource loader that can include literal files into the Clojurescript code (ns app.my (:require [shadow.resource :as rc])) (rc/inline "file.txt") I need a macro that ...
user2649762's user avatar
2 votes
1 answer
157 views

I have a class Foo from a third party library that has a lots of setters with a string argument named as set_parameter_name(std::string value). And I need to configure an instance of the class using a ...
Grigory's user avatar
  • 33
3 votes
2 answers
192 views

I am writing hardcoded calls of functions that takes array(s) in parameter, e.g. int foo(size_t length, const int array[/* length */]); In order to avoid the error-prone process of keeping track of ...
talentless's user avatar
0 votes
0 answers
159 views

Background I am on an ARM Cortex-A72. To access bit fields of my core's system registers I use a macro code generation mechanism. For the sake of simplicity, I replaced void operator=(const uint64_t v)...
salkin's user avatar
  • 177
0 votes
3 answers
261 views

I was asked to write a macro that checks whether the system is little-endian or big-endian, without using a variable, and for C89. C89 means lot of solutions requiring more recent versions of C cannot ...
Nir3001's user avatar
  • 11
5 votes
1 answer
137 views

Lets say I have some manner of type safety macro based on _Generic, which I use to wrap an actual function call to make it type safe: #include <stdio.h> void print (int i) { printf("%d\n&...
Lundin's user avatar
  • 220k
1 vote
0 answers
95 views

The goal is to write a Python macro that creates a new Writer document from a form letter template and fills in editable fields to automate repetitive correspondence generation. My problem is that I ...
Jayden67's user avatar
  • 183
0 votes
1 answer
94 views

I'm trying to make some stability promises for my library. Ideally I'd like to be able to mark the top of a file as stable/unstable, and emit some things as a result. Unstable allows unused, and is ...
gjh33's user avatar
  • 121
2 votes
1 answer
125 views

I'm in the process of porting NASM code to MASM, and I'm stuck on a NASM empty macro with 2 parameters and register usage with the _m suffix. example code: ;register defines %define arg0 rcx %define ...
rcgldr's user avatar
  • 29.4k
-1 votes
2 answers
165 views

#ifdef __augmented #define Prefix "@" #else #define Prefix "" #endif #ifdef __cplusplus #define Suffix "++" #else #define Suffix "&...
Adrian H's user avatar
3 votes
1 answer
168 views

There are two classes A and B, each having functions f and g (with the same signatures). The function bool is_A(uintptr_t ptr) returns true if and only if ptr points to an instance of A, and ...
AustinBest's user avatar
1 vote
1 answer
59 views

I have been working on a printer macro that uses Python to paste a letterhead onto a PDF message and then send it to the printer to print. In most of the companies' offices I set it up in, it works ...
silverbrook4's user avatar
0 votes
1 answer
159 views

I'd like to use a little macro logic in open code (i.e., not within a macro) to control my program. Specifically, if a certain macro variable exists and has a certain value of interest, I'd like to ...
Dagremu's user avatar
  • 521
3 votes
3 answers
169 views

I have a need to use a macro to write #defines and other macros in C for an embedded MCU. With the following definitions: // Define the pin state as wired to the board, CA (PIN controls -ve lead) ...
CJ1's user avatar
  • 78
1 vote
1 answer
122 views

I'm developing a C++20 application using OpenGL and SDL3, with a window_manager class that wraps windowing and OpenGL state management. Instead of writing separate member functions for each OpenGL/SDL ...
NeKon's user avatar
  • 312
2 votes
0 answers
102 views

TL;DR: I want to write (basic) custom macros that VS Code can render in markdown files I use VS Code with the Markdown Preview Enchanced extension to write mathematical documents in Markdown. I often ...
Sam OT's user avatar
  • 468
3 votes
0 answers
63 views

Is there a way to have the GNU assembly process a source file that contains macros, expand them, and then output the expanded equivalent code in a form that could be assembled by as? Basically, I'm ...
Bri Bri's user avatar
  • 2,012
3 votes
1 answer
171 views

The C++ macro __FILE__ typically includes the full path (with many compilers). For my tracing, I want just the file name, not the full path. Is there a built-in macro for this in any version of C++ or ...
Samuel Wenker's user avatar
1 vote
1 answer
65 views

I wrote couple data types (struct) to store small arrays and copy them by values: Array4 { base: int16|short, purpose: to store up to 4 values } Array8 { base: int32|int, purpose: to store up to 8 ...
leofun01's user avatar
  • 341
1 vote
1 answer
89 views

I'm using Emacs, and I have a macro that's like a switch for regexes, and runs an expression with variables bound to match results. The indentation isn't what I'd like but I can't find if there's a ...
John Graham's user avatar
0 votes
1 answer
87 views

Do we have any replacement for the following Scala 3.7 code: x.asType match { case '[type t <: S; t] => '{ apply[t] }.asExprOf[Any] case _ => report.errorAndAbort(s"...
Andriy Plokhotnyuk's user avatar
0 votes
3 answers
100 views

I'm trying to find an example of writing a C++ macro that can extract the entire doxygen string, or specific parts of a method for example: /** * Given a filename generated by writeVectorToFile, we ...
raaj's user avatar
  • 3,489
2 votes
2 answers
194 views

I want to do something like this for many parameters that are passed in through "-DPARAM_NAME=x" during compile time: #define CHECK_PARAM (PARAM_NAME,DEF_VALUE) \ Pseudo code : #ifdef ...
Ratin Rahman's user avatar
0 votes
2 answers
96 views

I'm relatively new to SAS and very new to Macros, so please forgive me if this is a basic question, but I haven't been able to find answers elsewhere that have worked for me. Basically, I have a SAS ...
jtscheirer's user avatar
4 votes
1 answer
100 views

In this assembly file below, the macro jump_table should automagically create ... a jump table to consecutively numbered labels like jump_0, jump_1, ... jump_<n>. It seems there is no loop ...
EnzoR's user avatar
  • 3,500
0 votes
1 answer
144 views

I want to write a macro which reloads all images inserted in a Calc document. I've heard of linking images, but I don't know the specific commands in LibreOffice Basic. So far the best answer I've got ...
christian2222's user avatar
2 votes
1 answer
119 views

Is there a way to filter macro or array data at compile time in C? For example: #define THRESHOLD 5 #define MACRO_DATA \ X( 1 ) \ X( 8 ) \ X( 3 ) \ X( 12 ) \ X( 5 ) // ...
phil5's user avatar
  • 21
1 vote
1 answer
156 views

In a scala 3.6.4 serialization library I am developing there is the DiscriminatorCriteria type-class that allows the user to determine which discriminator value to use for each variant P of a sum-type ...
Readren's user avatar
  • 1,290
3 votes
2 answers
76 views

With this: (defclass test-class () ((data :initarg :data) (other :initarg :other))) (defmethod test ((tc test-class) &key) (macrolet ((print-slot (slot) `(with-slots (,slot) ...
John Graham's user avatar
0 votes
1 answer
59 views

For debugging a scala 3.6.4 recursive macro I added many calls to quotes.reflect.report.info. But only a few are shown in the compiler output despite all the messages are different. Apparently, the ...
Readren's user avatar
  • 1,290
1 vote
1 answer
135 views

I'm making a small library that will (among other things) allow users to provide a class, A as a template argument to a base class, Base, and have all the (public) class fields of A get converted into ...
joe smor's user avatar
0 votes
0 answers
50 views

I have a macro for inventory replenishment prediction using Markov Chain. It uses data for last 10 days including today to predict inventory replenishment (rep R) or not (blank B). The model works ...
DM_Darko's user avatar
1 vote
1 answer
103 views

The method to call is the SAM of the following type class: trait DiscriminatorCriteria[A] { def getFor[V <: A]: Int } And the headType to pass as type argument (to type parameter V) was ...
Readren's user avatar
  • 1,290
0 votes
1 answer
134 views

I am working on modification of a translation document that utilizes references for duplicate strings. I want to run a macro that finds the REF:x, Sample Table REF en-US REF:1 Acknowledge **REF:x** ...
Mike Benson's user avatar
2 votes
2 answers
163 views

I have a type Type_##type dependent on a certain macro type_create: #define type_create(type) { \ typedef struct { \ type* ptr, \ } Type_##type; \ and I have a few macros dependent on ...
theKMan747's user avatar

1
2 3 4 5
278