Spyke

Posts

programming·Programmingbymkulko

[C question] Best way to change features of the program at compile time: #if((n)def) or if (const)?

Suppose that I have two features in my C program, feature foo and feature bar. I wish to be able to switch what features will be compiled into my program at compile time. The only two ways I know of doing this are:

  1. Using preprocessor directives
#define MYPROG_FEATURE_FOO 1
#define MYPROG_FEATURE_BAR 1

/* ... */

#if MYPROG_FEATURE_FOO == 1
/* code related to feature foo */
#else
/* code to prompt people to pay for the absolutely proprietary version of my program */
#endif

/* ... */

#if MYPROG_FEATURE_BAR == 1
/* code related to feature bar */
#else
/* code to prompt people to pay for the absolutely proprietary version of my program */
#endif

/* ... */

  1. Using the normal if with a const, non-volatile variable
const _Bool myprog_feature_foo = 1;
const _Bool myprog_feature_bar = 1;

/* ... */

if (myprog_feature_foo)
{
  /* code related to feature foo */
}
else
{
  /* buy proprietary version or no feature for you >:) */
}

/* ... */

if (myprog_feature_bar)
{
  /* code related to feature bar */
}
else
{
  /* buy proprietary version or no feature for you >:) */
}

/* ... */

What's the better way to do this? Is there a third way to achieve this that I have missed that's better than the above two?

View original on kbin.social
4
kbinStyles·Kbin Userstyles and Userscriptsbymkulko

[Question] Is it possible to change the vote icons using the Magazine panel?

I would like to replace the upvote and downvote icons in my magazine. Adding these CSS rules with the developer tools of my browser does exactly what I want:

.fa-arrow-up:before
{

content: "any fontawesome glyph";

}

.fa-arrow-down:before
{

content: "any fontawesome brand glyph";

    font-family: Font Awesome\ 6 Brands;
    font-weight: 400;
}

However, when I add this to the CSS section of the Magazine panel, the " symbols get replaced with ", breaking the vote icons entirely. Are there any other ways to change the vote icons using the Magazine panel (preferably without using JS)?

View original on kbin.social
1

You reached the end