Hey C folks, I have a question. My template has inline SVGs and they make the whole code unreadable. Is there a way to use a directive with a fopen to put the svg content inside it? Something like:

#define LOGO fopen("../assets/logo.svg", "r");

@thomasorus Unfortunately, you can't do that exactly but, you might be able to move your templates over into separate include files or as separate C files (containing the string as global variables).

@leimon Having them into another file as global variables could be a good solution yes! Thanks for suggesting it, do you have any demo of this somewhere?

Follow

@thomasorus This is a bit of a crappy example but, here I've essentially embeded a sample "template" string within a second C source file and then just make the other source file aware of it by using an extern. Hopefully this will give you some inspiration.

psty.io/f?q=d7a

FYI: This pastebin site only keeps things up for about 24 hours. So hopefully this reaches you in time.

Sign in to participate in the conversation
Librem Social

Librem Social is an opt-in public network. Messages are shared under Creative Commons BY-SA 4.0 license terms. Policy.

Stay safe. Please abide by our code of conduct.

(Source code)

image/svg+xml Librem Chat image/svg+xml