21 Mar 2022 |
le glowie de morta | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
double* hextorgba(char *hexstr)
{
int hexstrlen=strlen(hexstr)/2;
if (hexstrlen > 4)
{
printf("Invalid colour");
exit(1);
{
static double rgba[4];
rgba[3] = 255;
int i;
for (i=0;i<hexstrlen;i++)
{
char tmpstr[2];
tmpstr[0]=hexstr[i*2];
tmpstr[1]=hexstr[i*2+1];
rgba[i] = strtol(tmpstr, 0, 16);
}
printf("RGBA(%d, %d, %d, %d)\n", (int)rgba[0], (int)rgba[1], (int)rgba[2], (int)rgba[3]);
return rgba;
}
hextorgba("7f11e0");
}
| 11:38:47 |
le glowie de morta | it does not seem to compile | 11:38:53 |
le glowie de morta | * it does not seem to compile and i have no idea how to fix it lol | 11:39:02 |
le glowie de morta | * it does not seem to compile and i have no idea how to fix it lol | 11:39:09 |
tastytea | You can't put a function into a function like this, AFAIK. | 11:40:12 |
le glowie de morta | kek | 11:40:25 |
tastytea | Try making main() and hextorgba() 2 separate functions. | 11:40:43 |
le glowie de morta | still the same error rip | 11:41:41 |
NRK | tastytea: i think GNUC allows it | 11:41:51 |
tastytea | GNU C is awful and this is cursed. 😊 | 11:42:19 |
le glowie de morta | yep | 11:42:26 |
NRK |  Download image.png | 11:42:33 |
le glowie de morta | lol | 11:42:42 |
le glowie de morta | very cursed | 11:42:50 |
NRK | tastytea: gnuc has some nice features | 11:43:04 |
NRK | most of it is cursed tho, i agree | 11:43:20 |
tastytea | It's nice as long as you use a GNU compiler… | 11:44:26 |
le glowie de morta | does -c99 disable the gnu stuff | 11:44:58 |
NRK | no | 11:45:24 |
le glowie de morta | what does disable the GNU | 11:45:40 |
le glowie de morta | * what does disable the GNU | 11:45:49 |
NRK | i don't think you can make gcc strictly standard conformant | 11:45:58 |
NRK | best you can do is gcc -std=c99 -Wpedantic | 11:46:13 |
le glowie de morta | interesting | 11:46:23 |
NRK | you can also try compiling with tcc, it can catch some non-standard/implementation-defined stuff. | 11:47:12 |
tastytea | […] For example, -std=c90 turns off
certain features of GCC that are incompatible with ISO C90, such as the "asm" and
"typeof" keywords, but not other GNU extensions that do not have a meaning in ISO
C90, such as omitting the middle term of a "?:" expression.
| 11:47:32 |
le glowie de morta | i think my code broke the compiler it looks fine but it won't compile | 11:48:11 |
le glowie de morta | yay i broke gcc | 11:48:18 |
tastytea | eijrj390jr: You're missing some } . | 11:49:22 |
tastytea | clang-dormat should make it obvious. | 11:49:36 |