[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: dennis ritchie.png (108 KB, 1365x1024)
108 KB
108 KB PNG
What are you working on, /g/?

previous >>101130465
>>
>>101153696
int main(){const char * b = "Hello world!"; write(1,b,strlen(b));}

also zero indexing makes things easier, not harder.
>>
>>101153696
getting errors in header files
>>
watching a video about databases
>hi, I'm the instructor for this course 15-445/15-645 Database Systems at Carnegie Mellon University
>unfortunately I can't be on campus right now
>one of the TAS is having some problem and we're trying to lay low
>I'm not on campus right now so I'm also here in the back with one of the TAs
then later:
https://www.youtube.com/watch?v=xjhQ0e9Hlds&t=1180
>>
>>101153696
You are an insect
>>
>>101153986
rough day at work?
>>
File: yqha5j4ogxzxnyqwt5ey.png (102 KB, 1365x1024)
102 KB
102 KB PNG
>>101153986
>>
File: me.png (305 KB, 337x477)
305 KB
305 KB PNG
!
>>
These got old after about 15 minutes, man. Just wait until something better comes along and then spam that, fucking loser.
>>
>>101154481
this new AI is going to get annoying very quickly
>>
File: zkatwko7ebffy70zwa0c.png (114 KB, 1365x1024)
114 KB
114 KB PNG
>>101154508
>These got old after about 15 minutes, man. Just wait until something better comes along and then spam that, fucking loser.
>>
>>101153696
Do an AI roast about C++ or Bjarne Stroustrup
>>
>>101154534
reported :)
>>
File: g3vsoekjzacms6l4qe2z.png (97 KB, 1365x1024)
97 KB
97 KB PNG
>>101154541
Nvm I got one lol.
>>
>>101154484
HASKELL!!!!!!!!!!!!!!!!!!!!!!! YAY
YAY
YAY
YAY
YAY
I LUV MATHS
>>
File: Cat maid1.jpg (984 KB, 1200x1600)
984 KB
984 KB JPG
>>101154484
That is a good maid, thank you for posting her.
>>
is this that guilty tripnigger feeling? like your favorite wife finding out about the second family?
feelsbad
>>
>>101154552
>my feelings are hord
this is 4channel newfriend
>>
File: dz2fkwmrlemlr7t88vph.png (94 KB, 1365x1024)
94 KB
94 KB PNG
>>101154552
>>
>>101154552
Kek
>>
please make one with a toddler saying rule 2
>>
I got a segmentation fault in-kernel during a voluntary exit on error, looking at the bianry everything is fine with the exit function, the dmesg log said BUG so idk, the only other option would be speculative execution on one of the arguments within the struct (null pointer to it) i was supposed to pass to a function
>>
>>101154528
it got annoying about three minutes after retarded jeets realized it existed
generative ai is cancer
>>
>>101153696
I have this function
void
print_string(int fd, const char *s) {
if (fd == 1)
buffer(s);
else
write(fd, s, strlen(s));
}

I call it with a string literal in a few places. Like
print_string(2, "low voltage");

GCC optimizes strlen out in those cases but clang doesn't, it always calls strlen. Why?
>>
>>101156580
move it into header and mark it static inline, also stop being retarded and check if write succeeded or failed to write everything.
>>
>>101153696
https://github.com/cab-1729/Pandoc-Themes
WHY IS IT SOOOO HARD GJNHVGFDFVGG!!!!!!
0 contributions aaaaaaa!!!!!
>>
>>101156580
GNU Chad Compiler.
>>
>>101156580
try to make them const char * instead of char *
>>
>>101156699
this doesn't affect whether compiler inlines things, and it's already const, C is just a terrible language and relying on compiler optimizations to do trivial things like printing string literals will make you deal with shit like this
>>
can I just freestyle a game in cplussy or do I have to watch some shmucks flappy bird tutorial?
>>
File: 1703481620399781.jpg (299 KB, 1350x2716)
299 KB
299 KB JPG
>>101153696
I do NOT understand Go's Context and I'm considering suicide over it.
>>
>>101156828
you could start by detransitioning
>>
>>101156828
would break her pelvis if you know what i mean
>>
>>101156906
>her
>>
>>101156924
She is very gorgeuouse to me
>>
What can I not do on an old ass 32 bit cpu laptop? Do newer programming languages even support 32 bit architecture?
>>
>>101156979
with gcc, you can compile multitude of languages for 32bit system with just -m32 pretty much
>>
>>101153696
it's interesting reading through Agner Fog's microarchitecture guide. if you read it in order, you can get a sense of some of the design challenges play out as the microarchitectures evolve, like branch prediction constraining the usefulness of deeper pipelines. super interesting shit
>>
>>101156828
https://go.dev/blog/context-and-structs#conclusion
looks like RAII but for Go
>>
>>101157126
>hardware has basic nuance
>OMG SO IMPRESSIVE
we are the real deal, nigger.
>>
>>101153821
at least you aren't getting ICE's from using C++20 modules correctly.
>>
>>101157680
>ICEs
this would be good if passing a short instead of an int didn't create a whole new function.
>>
>>101157926
not sure what this has to do with anything, you can make a function that accepts long long and you will be able to accept any signed integers from signed char to long long
>>
Am I the only one who finds it degrading to read documentation?
>>
>>101158311
yes you're the only brown man on this board
>>
>>101158357
What about end user license agreements, do you read them too Mr. White Man?
>>
>>101158393
not documentation, rajesh
>>
>>101158401
It is legal documentation
>>
>>101158406
not technology
>>
>>101158418
The law is more important than any piece of technology
>>
>>101158428
yeah you cope about it in >>>/pol/ while I will continue breaking it because it's not enforceable.
>>
>>101158440
>not enforceable
Famous last words
>>
>>101153696
>"Unix is the future"
>still using a terminal 1970
but this literally shows that Unix really was the future...
>>
>>101158482
Currently watching anime that I didn't pay for, come enforce it.
Oh, also I'm redistributing it, some of the torrents have ratio in the thousands by now.
>>
>>101158562
>come enforce it
Ok. Give me your full name and address
>>
File: jej.png (11 KB, 640x734)
11 KB
11 KB PNG
>>101158615
enforce it without my help
>>
>>101158635
Well I could report you for violating US law but announcing reports is against the rules so I'll just say I may or may not have done that ^_^
>>
>>101158678
which US law did I violate?
>>
>>101158688
You have admitted to copyright infringement
>>
>>101158706
>saying things is illegal
to think I don't even live in US... /pol/tards are utterly mindbroken
>>
File: FP6CB62X0A01nzO.png (152 KB, 561x385)
152 KB
152 KB PNG
>>101158531
80. columns. wide.
>>
>>101158678
>>101154552
So is emoticons you insufferable newfag.
>>
>>101158834
80 columns wide is impractical if you give your variables/functions proper names
>>
>>101158872
Emoticons are not banned. You have no authority to speak on this topic but speak as if you do. That's basically impersonating 4chan staff which is in fact yet another violation of the rules.
>>
>>101158963
6.c
>>
>>101159192
>>>/global/rules/6/3
test
>>
>>101159250
grats on figuring out html. did you know you could do this on most sites https://lukesmith.xyz/articles/notes-on-learning-languages/#are-you-actually-thinking
>>
>>101154484
h a s k e l l
>>
Was gonna post about something else but then I saw that the "Nooo you'll get arrested if you pirate mp3s!" guy didn't die in 2005 like I thought he did and that's way more interesting desu.
>>
File: 1713766576627275.png (565 KB, 1210x925)
565 KB
565 KB PNG
Ok, I think I have to move on from Logisim to an actual HDL. I also need to simulate the hardware. Anyone know some good environments for a beginner?
>>
>language has a limit of 64k total objects per app
>not an issue though because the hardware has a 32kb memory limit
fucking kill me
>>
>>101153696
thank god for Apache Commons

>inb4 pajeet
>>
[  +0.000447] Device-monitor: retrieved physical configuration controller-mapped address.
[ +0.000027] Device-monitor: opened logs file.
[ +0.000021] Device-monitor: virtually mapped the configuration space.
[ +0.010066] BUG: unable to handle page fault for address: ffffb796c12be000
[ +0.000011] #PF: supervisor read access in kernel mode
[ +0.000003] #PF: error_code(0x0000) - not-present page

OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
>>
>>101160881
32kb is plenty. Have you actually hit this limit or are you just mad about the idea of hitting it?
>>
gonna try to map my pageroot and do the tables myself, which i had wanted to do anyway so i could do contiguous virtual memory for all of the ranges i am checking but after freezing my screen i realized that device registers need to be treated more carefully than "just dont burn it bro" so i am logging multiple files with an array of ranges instead, well, when i can even do BARs in the first place
>>
>>101161327
he is used to mmaping 200 gigabytes of memory and letting Torvalds program for him
>>
>>101161395
Oh it's just this kid talking to himself still? I should have paid closer attention before responding.
>>
>>101161579
>schizoing out
kek
>>
luckily i barely ever do anything with filesystems and files, but holy cow Python is ATROCIOUS for anything ever having to deal with files

i doin't think there's a programming language in existence that deals with files as terribly as Python
>>
>>101153696
>>101154481
>>101154534
>>101154573
>>101154621
>>101158635
>basedjak
/qa/ lost
what a shit thread made by manchildren.
>>
>>101153811
>>101153811
The OP meme image does not mention zero indexing but null termination of strings. You're outing yourself as a retard.
>>
File: move them.jpg (95 KB, 945x526)
95 KB
95 KB JPG
>>101158393
>>101158406
faggot
>>
>>101158482
>>101158615
here's that schizo again that regularly comes in to make sure /dpt/ is dead
fucking die already
>>
>>101153696
Why is /sqt/ so tranquil in comparison to this thread?
>>
>>101162861
REMINDER that xonotic won, reifaggot has never recovered and instead only spiraled deeper into pediphilia and jewish faith

>>101163082
Programming attracts people who dont mind spending 24+ hours awake, inside in one go,.
Tired == schizofrenic.
>>
>>101163082
people who visit 4chan to get help vs people who visit 4chan to avoid getting help
>>
>>101163082
Because it's summer. Kids probably don't go into /sqt/ as much because they already have no reservation about polluting the board with stupid questions in the first place.
>>
C libraries should be distributed as single header file.
>>
>>101162571
Worse is better.
>>
>>101164661
this shitty idea should've been distributed as a single post
>>
>>101164661
No, you're retarded and that doesn't solve anything.
>>
>>101165290
it solves everything, actually
>>
>>101165385
It's basically just forced static linking with extra steps, and does nothing to solve resolving dependencies, and wreaks fucking havoc on compile times.
Unless you're also proposing the ultra-retarded version where everyone ships a fucking copy inside of their own source tree, which then is a nightmare from maintainability and then you have multiple copies of a library trying to get compiled into the same thing, which breaks shit too.

I get that you've been programming C for 2 months and you think you're some super hacker or whatever, but just learn C library management is actually not hard, and pkgconf exists.
>>
why is making functions in powershell a pain or am I doing it the wrong way?

function Test {
param (
[Parameter(Mandatory=$true)]
[System.Collections.Generic.List[string]]$users,

[Parameter(Mandatory=$true)]
[string]$group
)

Write-Host "$users and $group"
}


but in python I can just do this which is way less lines
def test(users: list, group: str):
print(f"{users} and {group}")
>>
I'm reading some mailing lists and a guy is complaining about
>programming by extension
What does that mean?
>>
>>101166681
never head this term, hard to say without context
>>
>>101166681
Making a core program and extending it.
Like making a database handler as a bridge between user and data, and shoveling all business logic and graphics in the database. You can then program new features without recompiling.
AKA a coping man's Lisp.
>>
>>101166681
if it's about java, he might mean inheritance because of the "extends" keyword
current general practice is to use composition over inheritance
>>
>>101165442
>forced static linking
i get you have been programming in C for 3 months but in the real world we use things aside from the stl.
>>
>>101166681
by extension is a logical proposition
>>
Made a GUI queue for yt-dlp in C#
You add the URL and the program takes care of running yt-dlp for each one
>>
File: exterminator_wanted.jpg (158 KB, 816x1325)
158 KB
158 KB JPG
ok i can finally draw anime girls from imagination, now how do I git gud at competitive programming so i can pay rent?
>>
>>101166806
>>101167096
>>101166752
>>101166752
Thanks, this is what the guy meant, as he also criticised interfaces. Interesting to consider what is there really in OOP if you abort inheritance and interfaces. Probably just old-school procedural code with base classes and function calls.
>>101167289
kek
>>
>>101167637
>Interesting to consider what is there really in OOP if you abort inheritance and interfaces. Probably just old-school procedural code with base classes and function calls.
might very well be someone that got filtered by OOP
I can understand avoiding extending classes in favor of only using interfaces, but dropping any inheritance in a Java codebase, while doable, will certainly make your code go to shit as soon as you need to abstract anything
>>
File: 1680415933535091.jpg (76 KB, 900x900)
76 KB
76 KB JPG
learning about databases, it's interesting. although what the hell?
>SQL is declarative
>CREATE INDEX is needed to make efficient queries
>>
>>101167888
Indexes are created automatically on keys althougheverbeit.
>>
>>101167966
all databases have one index tables for each row of each table and it is done automatically when doing CREATE TABLE?
what about multiple-column index tables?
i'm reading this
https://www.sqlite.org/queryplanner.html
>>
>>101165808
Apparently there's an alternative syntax for parameters that's a bit more terse: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions?view=powershell-7.4#functions-with-parameters
>>
>>101168038
>all databases have one index tables for each row
*for each column
>>
>>101168038
It's called a clustered index.
>>
File: gpl.png (17 KB, 512x104)
17 KB
17 KB PNG
I hope you're doing your part to protect all of our freedoms, anon!
>>
File: ‪ 6890965321.gif (1.15 MB, 197x192)
1.15 MB
1.15 MB GIF
Only Apple and Microsoft make good ui frameworks, change my mind
>>
>>101168161
I do that why i use mit, companies are people and they have the right to freedumb too
>>
>>101168375
for me its https://plusnigger.org/MIT+NIGGER.txt
>>
>>101168375
>>101168400
>MIT
cuck license
>>
File: edd.jpg (93 KB, 620x670)
93 KB
93 KB JPG
>>101153696
>*laughs in buffer overflow*
>>
>>101168414
https://plusnigger.org/AGPL-3.0-only+NIGGER.txt
>>
>>101168447
FSF approved
>>
File: 1719054072379632.png (215 KB, 371x348)
215 KB
215 KB PNG
>>101161327
Discovered the limit when I tried to allocate an array of 1k integers (as a workaround to other, completely unrelated bullshit limitations) and it crashed, leading me to find out about the memory limit and that I was already dangerously close to it without realizing.

Future ideas involving three tiny monochrome bitmaps were scrapped after instantly blowing past the memory limit and workarounds using manual drawing or tiling even smaller bitmaps were too janky to proceed with on principle alone.

Just found out I can store an additional 32k in persistent storage and read it into memory as needed, but I've only got about 5k left to play with in active memory so this would still require slicing things up so unclear yet if it will actually help.
>>
>>101168503
Stallman wouldn't approve or racism though, he'd say it's toxic or something.
>>
>>101153696
Are there any C/C++ alternatives that give me identical speed+power without the bullshit? Did some embedded projects and C++ was fine, but even attempting to do some shit on the desktop is torture trying to manage dependencies and all the fucking stupid bullshit
>>
>>101168634
It would be approved as it doesn't infringe on any user freedoms
>>
>>101168447
>>101168503
yup

>>101168634
nigger
>>
File: Raymond Boyce.png (85 KB, 220x300)
85 KB
85 KB PNG
That moment when you have a faster than o(n) sort method for a 3d object and camera renderer but you didn't implement it so you have to use some bubble sort and you're unemployed.
>>
>>101167209
This is one of the most embarrassing posts I've seen someone make on here in a long time.
>>
>>101167209
Yea I've seen those programs around, those are the programs that have 1 minute + loading times.
>>
>>101168683
oh you sweet summer child
>>
>messagepack, avro, capnproto
which one am I supposed to use in cpp
>>
>12 files
>total size is 21.1 megabytes
>use 7zip to compress them into a single .zip file
>.zip file size is 20.9 megabytes
>>
>>101168653
Rust? Largely a C++ alternative. Cargo is both the build system and package manager. Maybe Zig too?
However, I think CMake works pretty well for C++.
>>
>>101168653
>but even attempting to do some shit on the desktop is torture trying to manage dependencies and all the fucking stupid bullshit
it's just add_subdirectory on cmake and you're done.
>>
Can I tell a C function that it should accept either a char array or an int array as argument?

Or do I have to make two separate copies of the function that do the same thing for each argument type?
>>
>>101168653
Swift
>>
>>101169729
void + element size and interpret all elements as numbers
>>
>>101169827
cheers, i'll try that
>>
>>101159999
witnessed

>>101169729
... are they going to be doing completely different things? if it is setting / copying just use string.h


>c++
>methods
>templates
almost there...
>no pointers to incomplete types
who is the fucking brainlet who designed this thing? ever heard of registers? there is a reason we can base + index
>but anon is all you want for the compiler to write the allocation code for you?
YES, just like with any other fucking class
>>
>101827
>101837
did the bot just samefag? they are evolving
>>
>>101169827
>>101169837
Fraid it didn't work, unless I misunderstood you
#include <stdio.h>

void array_set(void array[6], int count)
{
int i;

for (i = 0; i < count; ++i) {
array[i] = 0;
}
}

int main(void)
{
int i;
char test[6] = "pizza";

for (i = 0; i < 6; ++i) {
printf("%d ", test[i]);
}
putchar('\n');
array_set(test[6], 6);
for (i = 0; i < 6; ++i) {
printf("%d ", test[i]);
}
putchar('\n');

return 0;
}

results in
doesthiswork.c:3:21: error: declaration of ‘array’ as array of voids
3 | void array_set(void array[6], int count)
| ^~~~~
doesthiswork.c: In function ‘array_set’:
doesthiswork.c:3:21: warning: unused parameter ‘array’ [-Wunused-parameter]
3 | void array_set(void array[6], int count)
| ~~~~~^~~~~~~~
doesthiswork.c: In function ‘main’:
doesthiswork.c:15:14: error: declaration of ‘test’ as array of voids
15 | void test[6] = "pizza";
| ^~~~
doesthiswork.c:21:19: error: type of formal parameter 1 is incomplete
21 | array_set(test[6], 6);
| ^~~~~~~
doesthiswork.c:15:14: warning: unused variable ‘test’ [-Wunused-variable]
15 | void test[6] = "pizza";
| ^~~~

>>101169884
It's just for setting yeah. I know I can do it other ways, just curious
>>
>>101170039
nevermind the "void test[6]" in the errors, I just wanted to see what happened if I did that instead of char test[6]
>>
>>101170039
>>101170066
(this is the one that works with just plain char)
#include <stdio.h>

void array_set(char array[], int count)
{
int i;

for (i = 0; i < count; ++i) {
array[i] = 0;
}
}

int main(void)
{
int i;
char test[6] = "pizza";

for (i = 0; i < 6; ++i) {
printf("%d ", test[i]);
}
putchar('\n');
array_set(test, 6);
for (i = 0; i < 6; ++i) {
printf("%d ", test[i]);
}
putchar('\n');

return 0;
}
>>
>>101170039
there are a bunch of rookie mistakes in there. ask chatgpt to correct your code instead
>>
>>101170102
i'd rather you just told me
like i said above, the "void test[6]" was just trying shit, and array_set(test[6], 6) is also obviously wrong, but the one here is fine >>101170095
just trying to follow anon's instructions to take me from >>101170095 to what they were describing
>>
>>101170118
void array_set(void *array, int count, int type)
{
int i;

for (i = 0; i < count; ++i) {
if(type==0){
((char*)array)[i] = 0;
} else {
((int*)array)[i] = 0;
}
}
}

you can use an enum or switch-case or whatever instead
>>
>>101170134
>compiles into a segfault
>>
>>101170183
works on my machine
>>
>>101170134
ah I see, it needs to be a void pointer and you need to cast array into int pointer or char pointer. they didn't mention that at all
thanks

Is this style frowned upon by the way?
        if (type) {
((int*)array)[i] = 0;
} else {
((char*)array)[i] = 0;
}

>>101170183
It worked fine for me, as long as I didn't make char use the wrong type when calling the function
ie
char test => array_set(test, 6, 0);
char array => array_set(test, 6, 1);
>>
>>101170192
Oops, meant
char test => array_set(test, 6, 0);
int test => array_set(test, 6, 1);
>>
>>101170188
yeah because it compiles to exit(0);
>>
>101170200
I guess this is a bot
>>
>>101170192
just dont ever do ((different_pointer_t)pointer)[i] in code you actually need to work because it will compile into nonsense 100% of the time that the compile doesnt recognize it as "oh he is ugabuga setting a range of memory"
for example if you wanted to take the top short of an int in an int array, compiler will explode
>>
>>101170204
>projection
*ywn*

be a woman
>>
>>101170212
the hell is a "top short of an int"
>>
File: 1546247328379.jpg (76 KB, 857x740)
76 KB
76 KB JPG
I've been simplifying things dramatically by switching styles to something more functional.
Rectifying the mistakes made by myself in the past, by refactoring/rewriting currently.
The heat wave is ruining my productivity. I'm die.
>>
>>101170192
>Is this style frowned upon by the way?
it seems c11 has some fake function overloading with preprocessor directives (_Generic), so you could write it in a cleaner way.
other than this, there isn't really much todo differently. search for "c function overloading void pointer" and you'll see all examples are like that.
>>
>>101170237
>int
4 bytes, 32bits
>short
2 bytes, 16bits

the top of 4 bytes is 2 bytes
>>
>>101170273
i have never ran into an example that compiled to what was on the label
>>
File: 3atknf2the.jpg (80 KB, 700x484)
80 KB
80 KB JPG
>>101167446
Draw anime girls on to circuit boards.
>>
>>101170273
i was talking about
>if (var)
instead of
>if (var == 1)
since vars in C are treated as false if 0 and true if anything else

>>101170284
oh that's what you meant, ok
>>
>>101170307
what if var is 2?
>>
>>101170307
oh also anything with the highest bit set is treated as false because x86 assembly does signed comparisons
>>
>>101170351
if var is 2 it evaluates to true again
if that's not desired then i'd be specific about the value equality instead of relying on true/false
>>101170369
uuh, for me -1 still evaluates to true. and I'm on x86
>>
>>101170307
>i was talking about
with the if-else imo you do it the way you like best, there won't be any difference if you compile with -O3. but if you want to show it to your boss or something they'll probably be happier if you use a gay ass switch-case.

typedef enum inputTypes
{
INT,
DOUBLE,
CHAR
} inType;

void myfunc(void* param, inType type)
{
switch(type) {
case INT:
printf("you passed in int %d\n", *((int *)param));
break;
case DOUBLE:
printf("you passed in double %f\n", *((double *)param));
break;
case CHAR:
printf("you passed in char %c\n", *((char *)param));
break;
default:
printf("I like dicks\n");
break;
}
}
>>
>>101153696
US text messaging rules are so gay

twilio makes me have to fill out some dumb application. and have a dumb privacy policy and terms of service page on my site. what a bunch of tomfoolery
>>
>>101170273
Speaking of _Generic, you could use make a utility macro that selects the type integer based on whether the pointer is a char* or a int*. But then again, you can do more interesting things with macros
>>
>>101170134
>>101170039
Assuming you're not actually just setting the array to 9 where you could just use memset, you can honestly this kind of code can just be a macro.
#include <stdio.h>

// Add an argument for the length if you want to, to make it a bit more general
#define set_array(a) \
do { \
for (size_t i = 0; i < sizeof (a) / sizeof (a)[0]; ++i) { \
(a)[i] = i; \
} \
} while (0)

#define print_array(a, fmt) \
do { \
printf("{"fmt, (a)[0]); \
for (size_t i = 1; i < sizeof (a) / sizeof (a)[0]; ++i) { \
printf(", "fmt, (a)[i]); \
} \
printf("}\n"); \
} while (0)

int main()
{
int intarray[20];
char chararray[10];
float floatarray[5];

set_array(intarray);
set_array(chararray);
set_array(floatarray);

print_array(intarray, "%d");
print_array(chararray, "%hhd");
print_array(floatarray, "%.2f");
}

{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
{0.00, 1.00, 2.00, 3.00, 4.00}

Using a void * and maybe a switch over a type is sometimes called for, but I wouldn't say this is one of these situations.
>>
>>101170653
The world would be much better if people started using c with templates in g++ instead of macros
>>
>>101170386
yeah, gcc does test reg,reg and not cmp 0
>>
Writing functions within a class gets your productivity up by approximately 200%, i dont think i am ever touching C again desu.
>>
File: 1586981884564.jpg (304 KB, 1080x1118)
304 KB
304 KB JPG
>>101170870
Sorry, but if I was going to cut off my penis, I may as well full-troon out and use Rust.
>>
>>101170922
What’s the language for normal crossdressers? I like the penis
>>
>>101170932
C++
virtual Class File{
uchar_t name[64];
union {
struct{
File ** entries;
direntries_t entries_cnt;

File * override get_file(uchar_t * path, File ** entries){
ustd_t entries_iterator = 0;
uchar_t * comparison = entries[i]->name;
for (ustd_t i = 0; path[i] == comparison[i]; ++i){
if (path[i] == 0){
return entries[entries_iterator];
}
else if (path[i] == '/'){ get_file(path[i+i],entries[entries_iterator];}
}
return 1;
}


};
struct{
ondisk_t nonvol_position;
void * mem_contents;
user_t owner;
void write(filelen_t number, void * source); //TODO
void read(filelen_t number, void * destination); //TODO
};
struct{
pcibus_t bus;
pcidevice_t device
pcifunction_t function;
vendorid_t vendor_id;
modelid_t model_id;
devreg_t dma_ranges[6];
devreg_t write(devreg_t destination, devreg_t source); //TODO
devreg_t read(devreg_t source, devreg_t destination); //TODO
};
struct{ //say /dev/random
void write(filelen_t number, void * source); //TODO
void read(filelen_t number, void * destination); //TODO
};
};
mode_t mode;
};
Class Directory : File;
Class Storage : File;
Class Device : File;
Class Utility : File;
>>
*segfaults passing char as char pointer*
use rust
>>
>>101170039
$ cat zinita.c 
#include <stdlib.h>
#include <stdio.h>

void zinita(void *arr, size_t sz)
{
// memset(arr, 0, sz);
for (int i = 0; i < sz; ++i)
((char *)arr)[i] = 0;
}

int main()
{
int arri[6] = { 1, 1, 1, 1, 1, 1 };
char arrc[9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1};

zinita(arri, sizeof(arri));
zinita(arrc, sizeof(arrc));

int arri2[6] = { 0 };
char arrc2[9] = { 0 };

for (int i = 0; i < sizeof(arri) / sizeof(arri[0]); ++i)
printf("%d ", arri[i] == arri2[i] && arri[i] == 0);
printf("\n");

for (int i = 0; i < sizeof(arrc) / sizeof(arrc[0]); ++i)
printf("%d ", arrc[i] == arrc2[i] && arrc[i] == 0);
printf("\n");

return 0;
}
$ gcc zinita.c && ./a.out
1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
$ tcc -run zinita.c
1 1 1 1 1 1
1 1 1 1 1 1 1 1 1

You don't need a function to initialize arrays to zero. If you are writing GNU C and want to initialize to some other integer value then you can use designated initializers.
https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
>>
>>101172046
>Do retarded thing
>Compiler warns you that you're retarded
>OS tell you you're a retard
You might see a pattern here, anon
>>
File: work.jpg (78 KB, 1080x1080)
78 KB
78 KB JPG
Would you use WinUI 3 for your next windows project anon?
>>
File: style.jpg (109 KB, 724x813)
109 KB
109 KB JPG
Is it possible to solve this problem using the same 'style' I have here? i.e, using a for .. of loop? I know my code is wrong, not sure how to link 'the remainder of the array' after I pull the current element.
>>
File: style1.jpg (53 KB, 718x495)
53 KB
53 KB JPG
>>101173727
Why does it do what I want but backwards?
>>
>>101173818
>>101173727
ok i get why it's backwards but dont' know how to get it the way i want in this style, any help would be great i gotta go to work
>>
>>101173818
Because that’s how you programmed it. Try a little harder before you ask questions, this isn’t chatgpt

>>101173727
Recursive would be far easier, but a for loop is possible
>>
File: 1656835221169.png (30 KB, 200x193)
30 KB
30 KB PNG
>try rust
>do basic ass hardware emulation
>have to now add 300+ verbose u8::wrapping_add(a,b) / u8::wrapping_mult(a,b)/ u8 as usize everywhere

>try C
>do basic ass hardware emulation
>it just werks, and if it doesnt.. well..
>>
>learning bash and bash accessories
>barely scrapped the surface
>it's already being niggerlicious
Alright back to python, perl or some other shit it's just not worth it beyond being the most basic glue.
>>
It’s absolutely ludicrous that in the year of our lord 2024, the document format is being owned by Adobe. Not only that, pdf is a shitty format that can only display text and pictures and doesn’t adapt to different resolutions. In a time where people
>have different devices with completely different screen resolutions and aspect ratios
>multimedia is the standard
It’s unacceptable that pdfs are still the norm.

I propose a collective effort to make a new document system with the following capabilities
>multimedia embedding of pictures, videos and 3D models via a USD render delegate
>layout system based on grid and flexbox to support dynamic resolutions
>ditching the page format, printers are for boomers (individual readers can still make an adapter)

I’m not asking you to contribute right now. But, assuming such a project takes off, how many of you would be willing to contribute?
Assume the initial groundwork had been laid and there’s a working proof of concept of a writer + reader + document standard
>>
>>101174513
Why don't you actually prove there's something worthwhile to do? Shitty formats exist like epub and djvu as alternatives.
Most people just use md/rst -> html these days.
>>
>>101173114
In a C++ project? Probably not, I'll go with Qt. Perhaps in a C# project.
>>
>>101174036
What's worse is this is true of all nulangs. They all add a bunch of verbose code to do shit that is trivial in c. This is true even of the nulangs that have zero actual safety (ie memory safety) over c.
>>
>>101154600
WOW
O
W
>>
>>101156828
Go contexts are nodes in a linked list data structure. They are immutable. When you make a new context with value, you add another node in the linked list. When you look for values on the context, you do a linked list traversal.
It also carries signaling information so you can cancel some piece of work. Cancellation must be implemented by the observer of the context, however; goroutines cannot be unilaterally terminated by the caller, only signalled to.
>>
File: 1708936509068681.png (133 KB, 360x360)
133 KB
133 KB PNG
>>101174513
>and doesn’t adapt to different resolutions
nroff solved this in 1972
>>
File: 1691464890076652.png (459 KB, 2348x2096)
459 KB
459 KB PNG
how can I make the powershell try catch block better?

It looks messy
>>
File: aoc-2015-03.png (172 KB, 660x1266)
172 KB
172 KB PNG
I'm the one who asked about LISP in the last thread. Can I get some feedback on this AOC solution? I'd appreciate it if anyone more familiar with LISP could point out potential misconceptions or better ways of doing things.
>>
File: 1702763088706427.webm (237 KB, 320x240)
237 KB
237 KB WEBM
>>101170255
I've seen the light of first class functions and closures. One day I will migrate to LISP.
>>
>>101153928
Kek, what a champion
>>
>>101177017
Forget lisp, learn Haskell
>>
rate my stack

GOLANG
NIXOS
tailwind + htmx
>>
File: 1704753891108601.png (65 KB, 393x369)
65 KB
65 KB PNG
>>101177308
Good.
>>
>Working on big project at work
>I architected the entire thing
>other engineers pushing back on a key design component because they think it'll be hard for them to code
>boss is 50/50 on my solution vs theirs
>they say they'll have to rewrite the core module of their service to make it work
>I go in their code
>Come up with a solution in 10 lines involving a binary search tree of nothing but integer comparisons
>entire solution adds tow O(logn) calls after an O(n) loop (i.e: full module is O(n) + O(logn))
>it was 10 lines of java

I think these people are intentionally sabotaging me
>>
>>101153696
Is there a way to intercept a post request without knowing the payload? I've used axios in the past for GET requests and those work fine but apparently you need to know the payload to intercept the POST request. Is there not a way to intercept all POST requests? Or is there another library that does it? Before you ask, it's impossible to know the payload ahead of time.
>>
>>101177464
What does "intercept" mean, here? Intercepted by who
>>
>>101177464
https://developer.chrome.com/docs/devtools/network
https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/
https://mitmproxy.org/
https://mitmproxy.org/posts/wireguard-mode/
>>
Should pointers instantiated in a loop be assigned nullptr on each iteration?

Example:
for (int i = 0; i < 5; i++)
{
void* SomePtr = ReturnsAPtr();

// Do something with SomePtr

SomePtr = nullptr;
}
>>
>>101177705
No, you are redeclaring a new SomePtr on every iteration. The next time through is creating an entirely new object and resetting it at the end is pointless because it will be soon destroyed. Research the distinction between declarations and definitions.
>>
Good morning, sirs! Javeet learning Python here.
I'm used to an established folder structure in project, but it appears there is no one good solution for Python projects. What do you use?
Also, is OOP the way to go in Python or should I just export functions?
>>
>>101177861
for me it's hatch
>>
>>101177705
The only reason to set a pointer to null explicitly when you're done with it is when you will hold onto that pointer beyond the current scope. e.g: you delete the last element in a linked list, so the 2nd to last element now points to null. If the pointer is about the fall out of scope there's no reason to set it to nullptr and I think a good compiler will optimize that away anyways
>>
>>101177884
maybe look at rye too
>>
>>101177861
Directory structure:
https://packaging.python.org/en/latest/tutorials/packaging-projects/
https://docs.python.org/3/tutorial/modules.html#packages

Functions are objects and modules containing functions are too. You cannot escape "OOP" in Python.
>>
>>101177308
Switch Go for Swift or Nim and you're golden
>>
>>101177508
I have a 3rd party script that is calling some HTTP requests. I want to wait for any POST requests with a known URL but unknown payload and intercept the response. If it's an error I want to do something with that information.
>>101177562
Yh I can check on devtools fine and it's a POST request but there's no way of predicting the payload since the 3rd party script is generating it on the go and it's different each time.
>>
>>101178112
>Swift
Appleshit lmao
>>
>>101177508
To be more specific, I want to intercept this in react and do something like render an error message to the user.
>>
>>101178128
https://docs.mitmproxy.org/stable/mitmproxytutorial-interceptrequests/
>>
>>101177884
>>101177989
Thanks, I'll check it out.
>>
>>101178161
React. I need to do this in react which I hate but I'm forced to do so.
>>
File: 1719513968098407.png (120 KB, 375x339)
120 KB
120 KB PNG
>wanna learn to code
>can't think of a signle thing worth making
>>
>>101178368
please consulting of the google
https://stackoverflow.com/questions/5409428/how-to-override-a-javascript-function
>>
>>101153696
another doxing thread? you kidding me?
>>
>>101178418
"To code" really means "to write programs" so if you have nothing you want to make then what is your motivation for wanting to learn?
>>
>>101178501
It's fun. I have been using python for job and it has been fun. I wanna go deeper but can't think of a thing.
>>
>>101178460
Kys
>>
File: haskell.png (7 KB, 397x131)
7 KB
7 KB PNG
opinions on this side project idea?

Symbolic Math GTK Suite
Desktop GTK3 Application which allows the user to write symbolic mathematical expressions and see the result immediately. Numerous different results will show and are available for viewing to conceptualize the math in different ways. A simple numerical readout, and also graphical readouts for things like graphing functions, and 2D/3D visualizations.

The purpose of this project is to learn numerous Mathematical concepts and also learn Haskell and functional programming through the symbolic parser.

The project's core math logic, GTK3 GUI, and graphics will be written completely in C.
The project's symbolic parser will be written in Haskell.

The project will not utilize parsec, I'll build the parser from scratch.

Purpose:
-Learn basic and advanced math.
-Learn functional programming

Math Concepts Included:
-Arithmetic
-Algebra
-Geometry
-Trigonometry
-Linear Algebra
-Calculus I through Multivariable Calculus
-Discrete Math
-Probability and Statistics

Components
-Math Logic. Comprehensive headless C Math Library ( C )
-Symbolic Math Parser for notation ( Haskell )
-GTK3 GUI Interface ( C )
-Graphical Representations ( C )

Tech Stack
-C
-Haskell
-GTK3
>>
>>101179228
i think you're too optimistic about how you'll be able to analyse it
also its kinda odd to have so much in c then just the parser in haskell
>>
>>101179228
>The project's core math logic, GTK3 GUI, and graphics will be written completely in C.
why do the math logic in C? wouldn't Haskell be way more fit for that purpose, if we're talking about higher symbolic math?

sounds like a fun project, do you have the chops to pull it off? I ask because this sounds like some kind of project proposal. why not just dive in ASAP?
>>
>>101179607
the real question is why not do it all in haskell which literally has gtk3 bindings
>>
>>101179262
>>101179607

I mainly develop in C so if I'm going to go through all this math I might as well make my own C library out of it.

I'm sure the Haskell parser from scratch will be more than enough for Haskell learning.

Yeah, I think I can pull it off, I just wanted to post about it.
>>
>>101179715
because I mainly develop in C and if I can get a comprehensive custom C math library out of it, then it's going to be two birds with one stone.

maybe I optimize that library later and use it in my other projects.
>>
File: 1672611584269428.png (209 KB, 600x613)
209 KB
209 KB PNG
>>101179228
>Desktop GTK3 Application which allows the user to write symbolic mathematical expressions and see the result immediately. Numerous different results will show and are available for viewing to conceptualize the math in different ways.
>The project's symbolic parser will be written in Haskell.
>The project will not utilize parsec, I'll build the parser from scratch.
you're gonna find parsing math expressions is ambiguous
>>
>>101179725
>Yeah, I think I can pull it off, I just wanted to post about it.
ah ok
good luck and keep us posted
>>
>>101176106
Put the catch on the same line as the brace of the preceding line. Much more elegant; ties it to the associated try instead of pretending it is unrelated.
Or just don't use powershell.
>>
>>101158936
I used to work with someone who gave his loop variables 40 character names.
When he left, we immediately shortened them by 39 characters. Just sayin'...
>>
Is there a good compilation of recursive problems with solutions? (preferably in C/C++ or python)
>>
hi i am making 3 things

1. an emacs lisp mode for detecting your mood
2. a firefox extension that stores your reccomendation data across 10 different websites and then gives you access to an interactive and explorable latent representation of the search space when ranked by similarity

basically you can say "i want to wach family guy"
and then you can say "whats that joke louie ck said"
and then you can ask "was kanye really anti semite or was that a psyops?"

and it organizes all your bookmarks and does automagic bucketing / back linking / formatting and spaced reptition using flash cards so you reain all the knowledge. its kinda like apple intelligence, but only for linux, and you 100% own all the data and gpu shit and source code.

3. a robot assassain that pretends to be a doctor.

anyway please let me know how to make landing pages or if you see any i should use also what are lottie files
>>
>>101180243
https://leetcode.com/problemset/?topicSlugs=recursion&page=1
>>
>>101180146
haha goddamn
that's next level anal retentiveness
>>
File: code.png (128 KB, 2410x515)
128 KB
128 KB PNG
I'm using PhysFS to load some files from a .zip. The code in the pic does NOT work, because apparently the "buffer" vector has to be in-scope when calling Mix_LoadWAV_RW(), otherwise the Mix_Chunk* will be a nullptr. Can anyone think of a nice way around this? Obviously I can just copy the code from the right into the left, but then I'd have a BUNCH of duplication, since I'll also be using this same method for music, sprites, text, etc.
>>
>>101180980
put the two into one struct and make sure it doesn't move
take the buffer by lvalue reference and assign it
take an operation to perform on the result and call that before the buffer is destroyed
>>
>>101179228
You should steal algorithms from Maxima and company
>>
>>101174133
>bash is useless
yep
history | perl -MList::Util=pairmap -anE '$count{$F[1]}++; END { say for map { "$_->[1]\t$_->[0]" } sort { $a->[1] <=> $b->[1] } pairmap { [$a, $b] } %count }'
>>
File: file.png (142 KB, 1085x1024)
142 KB
142 KB PNG
rate my C++23 unix sockets wrapper /dpt/
>>
>>101180980
Can't you add Mix_LoadWAV_RW call to the right since you're using it only once? If you have multiple different functions operating on SDL_RWops returned from the right, make it take a callback and pass a lambda if needed.
>find() != end()
contains()
>>
>>101153696
Supposed to be finishing my masters degree but I am instead annoying the trannys and feds.
>>
>>101156580
I investigated this further. I call print_string from within a loop in main() and return an error code. If I change return x with _exit(x) clang optimizes strlen out
>>
>>101181836
Seems like a lot of pointless masturbatory boilerplate.
>>
>>101167888
>learning about databases, it's interesting.
how the fuck do people like databases
how do you like sql
>>
File: 20240627_223252.gif (2.41 MB, 640x640)
2.41 MB
2.41 MB GIF
>>101153696
comfy
>>
>>101183065
how they work is interesting, they are supposed to magic you know
>how do you like sql
sql is gross but at the same time it's sort of powerful
>>
File: enough room.png (410 KB, 1900x1400)
410 KB
410 KB PNG
>>101181836
>>101183027
In Plan9 C this is just
#include <u.h>
#include <libc.h>
...
path = argv[1]
fd = dial(netmkaddr(path, "unix", "discard"), 0, 0, 0);
if(fd < 0) {
sysfatal("can’t dial %s: %r", path);
}
>>
>>101184595
That looks better. I don't miss doing low level socket shit.

What is always a pain is https.
>>
>>101184595
Why the hell does the C version not have indentation?
Also it should be using getaddrinfo, or even some other DNS requester (ideally async) if you wanted to be extra fancy.
>>
File: 9 sockets.png (415 KB, 1900x1420)
415 KB
415 KB PNG
>>101185331
I couldn't find the original source paper's example. The one I did find was partial and has messed up formatting.
(https://docs.huihoo.com/plan9/Plan9.pdf - Pg.23)
Updated it.
Refine the function and suggest modifications if you want to.

#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
//...
struct sockaddr_in sock_in;
struct servent *sp;
struct hostent *host;
//...
memset(&sock_in, 0, sizeof(sock_in));
sock_in.sin_family = AF_INET;
f = socket(AF_INET, SOCK_STREAM, 0);
if (f < 0)
error("socket");
if (bind(f, (struct sockaddr *)&sock_in, sizeof sock_in) < 0) {
error("bind");
}
host = gethostbyname(argv[1]);
if (host) {
sock_in.sin_family = host->h_addrtype;
memmove(&sock_in.sin_addr, host->h_addr, host->h_length);
//...
} else {
sock_in.sin_family = AF_INET;
sock_in.sin_addr.s_addr = inet_addr(argv[1]);
if (sock_in.sin_addr.s_addr == -1)
error("unknown host %s", argv[1]);
}
sp = getservbyname("discard", "tcp");
if (sp)
sock_in.sin_port = sp->s_port;
else
sock_in.sin_port = htons(9);
if (connect(f, (struct sockaddr *)&sock_in, sizeof sock_in) < 0) {
error("connect:");
}
>>
File: file.png (7 KB, 348x214)
7 KB
7 KB PNG
would you guys say this is very niggerlicious or is it forgivable?
>>
>>101185534
#include <netdb.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
// For this example, these hints are not actually needed, but the
// original included SOCK_STREAM, and NULL hints would include
// SOCK_DGRAM/SOCK_SEQPACKET too.
static const struct addrinfo hints = {
.ai_flags = AI_ADDRCONFIG,
.ai_family = AF_UNSPEC, // IPv6 or IPv4 is fine
.ai_socktype = SOCK_STREAM,
};
struct addrinfo *info;
int sock = -1;
int res;

res = getaddrinfo(NULL, "discard", &hints, &info);
if (res != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(res));
return 1;
}

for (struct addrinfo *iter = info; iter; iter = iter->ai_next) {
sock = socket(iter->ai_family, iter->ai_socktype, iter->ai_protocol);
if (sock == -1) {
// May not actually want to print this to not produce
// unnecessary error messages
perror("socket");
continue;
}

// Deliberately not call bind, because connect will give us an
// ephemeral address if we don't.

if (connect(sock, iter->ai_addr, iter->ai_addrlen) == -1) {
// Same as above
perror("connect");
close(sock);
sock = -1;
continue;
}

break;
}

freeaddrinfo(info);

if (sock == -1) {
fprintf(stderr, "Failed to connect to any address\n");
return 1;
}

// Just testing that it actually set up correctly.
// `sudo nc -6l 9`
// 9 is the discard protocol socket.
char garbage[] = "qwertyuiopasdfghjklzxcvbnm\n";
send(sock, garbage, sizeof garbage - 1, 0);

close(sock);
}
>>
>>101156742
>C is just a terrible language and relying on compiler optimizations to do trivial things like printing string literals
So you're complaining that the compiler is smart enough to know about C Language intrinsic functions, and can turn a function call into a constant value because it can make the determination at compile time?
How is this retarded?
>>
>>101185972
if you mean colors yeah they suck
if you mean { on its own line and no space between if and ( then yeah that sucks too
>::
that sucks worse
>>
>>101186091
both wrong
>>
>>101172579
I will call that code retarded myself
i must have been so tired that my iq dropped by half, i unfucked it and some other files today, i came back to the thread thinking i would have 20 (You)s calling me a nocodeshitter kek
>>
>>101185123
>cant into opening a file in memory and writing to / reading from it
sad where programming has gone
>>
>>101186091
:: is nice to remember that something is a singleton
>>
>>101156828
Probably the best way to understand them is their use. So here's the problem they solve: if you have an operation that spans multiple concurrent processes, possibly across RPC boundaries, how do you terminate that operation? Contexts are the answer to that question: you have a helper variable with a channel that is closed when the operation should be canceled. Functions taking a context that run an indefinite or long-running loop should select{} over the context's channel and, if it's closed, perform cleanup operations and return. For RPCs, you can set the context up to automatically close when a specified timeout is reached, and I believe gRPC natively supports sending a context with a timeout over the wire so that a timeout can persist across multiple RPC calls (e.g. service A gets called with timeout 30s, exhausts 7s, calls service B - service B now has a timeout of 23s).

If you aren't trying to solve this problem in your program, don't use contexts. If a function you're calling takes a context, use context.Background() to create a simple context that does nothing. If you have a reason to use them, then their behavior will start making sense very fast.

(There's some other stuff you can do with them, but it's probably not relevant.)
>>
File: aoc2015day3.jpg (243 KB, 1377x656)
243 KB
243 KB JPG
>>101176645
I'm not going to read all of that code, but here's my solution in Clojure

also, >>>/g/lisp
>>
>>101155888
t. Arttranny on suicide watch
>>
How do you do progress bars in tkinter (in python)? I made a progress bar and passed it to a function which increments it as it does it's thing, but since bar only gets updated in the main loop it's static while the function is running.
>>
>>101187822
Run the function in its own thread or use async.
>>
>>101187876
Thanks
>>
>>101179228
symbolic math is hard for a reason. You can try to implement the human way of doing things but you will soon realize it can't be done elegantly.
>>
Is casting uint64_t to uint16_t safe in c++? i have bad experience in gcc and would prefer not writing assembly
>>
i was bullied for creating makefiles for my latex projects
>>
>>101188188
its safe if you do static_cast
but the behaviour might not be what you expect

lookup the default static_cast operator on uint64 and uint16. It'll obviously cut off something but im not sure where it cuts off
>>
>>101188544
just looked it up for you
c++ defines it to always truncate the high bits
>>
My doujin tool is progressing well. It's my first time trying to do any kind of gui stuff.
>>
>>101188412
you should have made a bash script
makefiles suck dick
>>
knock knock
race condition
who's there?
>>
>>101189438
:)
>>
you'd think after more than a decade, browser devs would have figured out how to write a video player that doesn't "buffer" inbefinitely until you give the player a nudge by interacting with it in some way
why is this industry so fucking incompetent
>>
>>101189477
they aren't paid to make a good product retard
>>
>>101189438
something like vidrelated is the first thing I think of when I hear "race condition"
>>
>>101189477
works on my firefox
>>
Can someone find the average of my two-sum solution? I know it's worse than the hash solution, but is it better or worse on average than the naive solution? My gut says it's the same or worse
compare the array for target
if you find it then compare the array for 0
repeat for target+-1..n and if you find it compare the array for +1..n
>>
>>101189503
doesn't work on mine
>>
>>101189525
just write it out as code and benchmark it?
>>
>>101189525
if target is bigger than n it's worse
>>
How do you into c?
I wrote this
main() 
{
int dest;
for ( int i = 0; i < 1000 ; i++ ) {
asm("popcnt %1, %0;"
"and $1, %0"
: "=r" ( dest )
: "r" ( i )
);
printf ( "%d", dest );
}
}

but I want something like this:
main()
{
char arr [ 1001 ];
int dest;
for ( int i = 0 ; i < 1000 ; i++ ) {
asm( "popcnt %1, %0;"
"and $1, %0"
: "=r" ( dest )
: "r" ( i )
);

arr [ i ] = ( char ) dest;
}
arr [ 1001 ] = '\0';
printf ( "%s", arr ); /* just doesn't print */
}
}

or this
main()
{
char arr [ 1000 ];
int dest;
for ( int i = 0 ; i < 1000 ; i++ ) {
asm ( "popcnt %1, %0;"
"and $1, %0"
: "=r" ( dest )
: "r" ( i )
);

arr [ i ] = ( char ) dest;
}
write ( 1, arr, 1000 );
}

But the last 2 programs just don't print anything.
>>
>>101153696
I frequently get dc'd from my network with my new ISP so I wrote a script & systemd service that checks my network status every 2 seconds, and if I get dc'd for any reason it reconnects me. I would rather deal with this than speak to Pajeet over the phone for 5 minutes.
>>
>>101189897
I'm dumb they work fine, I just forgot to add '0'
>>
>>101168519
depending on your usecase you can try scanline rendering
>>
>>101190133
and 1 is 1.06 +- 0.14 times faster than 0
and 2 is 1.18 +- 0.16 times faster than 0
which doesn't sound like a lot but in (pretty much) the same time interval that's
0 average 6k runs w/ no optimization (max ~7k w/ o2/3)
1 average 7.5k runs w/ no optimization (max ~9k w/ o2/3)
2 average 8 runs w/ no optimization (max ~10k w/ o2/3)

Probably best to not loop over functions in c, even with an optimizing compiler, maybe gcc does better with asm() but don't hold your breath.
>>
>>101189897
just write them as %%al and %%cl
>>
>>101190424
That's not how popcnt works
>>
bump
>>
>>101153696
done paging for x86
>>
>>101189897
#include <stdbit.h>

stdc_count_ones(i);
>>
>>101188544
so if i want to do 32bit into 64bit i am fucked?
good to know, thank you Anon.
>>
>>101189438
>race conditions
impossible to prevent in userspace, either futex or into arrays.
>>
>>101192411
>impossible to prevent in userspace
there are ways, but most programmers don't know a damn thing about writing realtime code
>>
>>101192534
>into arrays
what did you miss? i was assuming that he was talking about LCOCK# or whatever
>>
Am I doing SFINAE right?

template<typename T>
optional<T> tryParseToken(string const& input, string& parsedString);

template<>
optional<NumberToken> tryParseToken(string const& input, string& parsedString) noexcept(false)
{
smatch matches;
if (regex_match(input, matches, s_numberRegex))
{
f32 value;
stringstream ss;
ss >> value;
if (ss.fail())
{
throw new InvalidNumberException(matches[0]);
}
parsedString = matches[0].str();
return NumberToken(value);
}
return nullopt;
}

template<>
optional<StringToken> tryParseToken(string const& input, string& parsedString) noexcept
{
smatch matches;
if (regex_match(input, matches, s_stringRegex))
{
parsedString = matches[0];
return StringToken(matches[0].str());
}
return nullopt;
}
>>
>>101192664
i don't think that applies to explicit template specialisation
>>
>>101192664
That's just an incomplete type, SFINAE is something else.
>>
>>101193075
thats not an incomplete type
>>
>>101193186
If you try to instantiate it with anything else then it will be
>>
>>101192294
>picrel vs 2 assembly instructions
The absolute state of you
>>
File: mypicwhenihavenoface.png (61 KB, 1133x360)
61 KB
61 KB PNG
>>101193283
>>
>>101192664
>tryParseToken
disgusting
>>
>>101193298
Oh no, a standard library header has stuff in it!
>>
>>101193530
header files are free if your time has no value.
>>
>>101192664
>optional
how about you just parse the fucking token and give a best effort token and not some nigger shit
>>
>>101193608
>>optional
>how about you just parse the fucking token
that part is right, reading a token can fail
>give a best effort token
THAT is some nigger shit
>>
>>101193608
5
>>
I’m generally very unpretentious when it comes to programming but christ NO ONE else seems to have even a remotely good grasp of git and I don’t understand how they function. It’s a DAG of the repository state with movable tags it’s really not complicated.
>>
>>101194066
don't care. git is not programming, programming is not git
>>
File: sicp snake.png (27 KB, 666x768)
27 KB
27 KB PNG
>>
>>101194385
what the fuck does it say?
>>
>>101194066
git clone
do changes
delete git
reupload project cardano.contract.final.final.v6.final.0.1.xlsx
>>
>>101194421
It says
>You need a 4chan gold account to read this message.
>>
Is there a convention in C for the order of the arguments of a function?
Alphabetical? By type? Whatever?
>>
>>101194591
>>101194591
>>101194591
>>
>>101194431
lol. cope you incel dweeb
>>
>>101194447
>>101194753
>>
>>101193283
>compiles to what you want in real programs
nothing personal, kid

also if you do objdump you will see that when giving you registers the compiler wont bother integrating them into the code, instead it will back them all up and say "play with the xbox"
so the builtin is just faster.
>>
File: a.png (159 KB, 1804x1126)
159 KB
159 KB PNG
>>101194838
>when giving you the registers
>integrating them into the code
You write like a cargo culting Indian. If you are trying to say that the intermediate won't have popcnt and and then you are wrong, I don't care about the name of the register it uses.
The builtin not only pulls 20000+ lines of useless code through the compiler, it is probably 1000+ assembly instructions itself. Not to mention a call. Please explain how this beats 2 sequential instructions in a ~50 loac plus a write syscall program. If you could do it in English I would be impressed.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.