[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - daily programming thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 12
File: ll_smart_x64.png (19 KB, 600x371) Image search: [Google]
ll_smart_x64.png
19 KB, 600x371
RIP Linked Lists (1956-2016) Edition

Old: >>54643873
>>
>>54651035
#include <stdio.h>

typedef struct unit unit;
struct unit {
char *s;
unit *next;
};

#define cons(x, y) (unit[]) {{x, y}}

int main(void)
{
unit *lst = cons("this",
cons("is",
cons("a",
cons("compile-time",
cons("linked",
cons("list", 0)))))), *l = lst;
do {
puts(l->s);
} while ((l = l->next));

return 0;
}

>>
>>54651064
Wow pretty cool! I've never thought of doing it like this before. Smart method
>>
C users are dumb as shit
>>
File: rich-hickey[1].jpg (117 KB, 1005x1005) Image search: [Google]
rich-hickey[1].jpg
117 KB, 1005x1005
https://www.infoq.com/presentations/Value-Values

based HICKEY
>>
>>54651174
>dat laptop
>dem stickers
>>
File: blackmale.jpg (63 KB, 540x960) Image search: [Google]
blackmale.jpg
63 KB, 540x960
is it true?

>>54642404
>>
>>54651273
Sometimes. It pretty popular to write apps in JavaScript
>>
>>54651273
partially
>>
>>54651273
All the good apps are native
I have seen javascript apps, they are dogshit
>>
another one
https://vimeo.com/113588389
>>
There is no reason for manually allocating memory in 2016.

Let's be honest: most of us aren't as smart as we think we are. C code of a certain size will always be more leaky and bug ridden than Java of the same level of complexity. I would say that for everything other than low-level drivers, C should be considered harmful.
>>
>>54651393
That's true, even people that are confident in their C skills make stupid mistakes that result in stack corruptions, buffer overruns and such.
>>
>>54651393
>most of us aren't as smart as we think we are
especially arrogant C tards
>>
>>54651393
>C code of a certain size will always be more leaky and bug ridden than Java of the same level of complexity
I'm fairly sure that you will find less bugs and memory leaks in the Linux kernel than fucking """"ANY"""" Java project consisting of 15 million lines of code.
>>
>>54651429
stay delusional, and keep thinking you write linux grade C
>>
>>54651127
>>54651064
What's the point of using a linked list if you know what elements you want at compile time and won't be adding or removing anything?
>>
>>54651393
Try running
valgrind /usr/bin/java
on your command line and tell me what you see wrong. And that's just without running a program or anything. Just the stupid interpreter.
>>
>>54651393
If you can't manage manual memory allocationyou shouldn't be programming.
And having a gc doesn't alleviate the need for thinking about resource management, especially when you start using non-heap type resources like files, locks, threads, etc.
>>
>>54651442
Well, considering I have a patch that has been ack'ed and is awaiting approval for reasons other than code quality, I do.
>>
>>54651393
>there isn't a reason to manually manage memory when writing CRUD enterprise Java apps
ftfy
>>
>>54651273
Its not just mobile apps. Spotify's desktop client is javascript, for instance.
>>
>>54651429
https://www.cvedetails.com/product/47/Linux-Linux-Kernel.html?vendor_id=33
>>
>>54651444
It looks like a cool exercise. Doesn't have to have any practical use necessarily.
>>
>>54651455
>If you can't manage manual memory allocationyou shouldn't be programming.
C tards can't even zero a 2d array, yet they insist on programming
>>
>>54651470
>denial of service constitutes over 50% of vulnerabilities
It pretty much confirms what I said, when did DoS have anything to do with code quality and not the protocol being used?
>>
>>54651481
>C tards can't even zero a 2d array
memset
>>
>>54651493
uhhh learn what DoS means
>>
>>54651515
yes, but some delusional fucktard in the previous thread insisted on that it was UB
>>
>>54651519
Denial of Service
Disk operating system
???
>>
>>54651515
you can also use bzero
>>
>>54651524
Yes, when doing it on a pointer to pointer, like the original anon asked.
>>
>>54651524
Probably a webdev then.
>>
Why is it that an HttpUrlConnection's connect method finishes quickly if I'm stepping over it in the debugger while it's taking forever for it to finish if I'm running the program normally?

>inb4 >Java
Yes, I know I'm using Java, but I'm somewhat of a beginner, so cut me some slack here. I haven't gone that far in learning C so as to use a third party library like libcurl to do some simple network operations.
>>
>>54651286 (you)
>>54651320 (you)
>>
>>54651537
he fucking didn't, see for yourself >>54650690, it's just your shitty assumption that your self-centered arrogant fuck decided was the objective truth
>>
>>54651526
> Double free vulnerability in drivers/net/usb/cdc_ncm.c in the Linux kernel before 4.5 allows physically proximate attackers to cause a denial of service (system crash) or possibly have unspecified other impact by inserting a USB device with an invalid USB descriptor.

literally memory corruption is considered a DoS
now piss off fag
>>
>>54651524
>cant answer the original question
>gives answer to a different question
>autistically tries to claim that it answers what the person asking really meant to ask
This is why I stopped posting in the /dpt/
>>
>>54651336
this

>>54651273
it depends, if it's a pizza ordering app or uber of course it involves web shit (server access over the interwebs), but even for those apps it helps with responsiveness and battery drain if as much as possible of the app is in native code and not browser cancer

serious games should of course be in native code, not in web cancer shit
>>
>>54651557
>he fucking didn't
He did: >>54650801
>>
>>54651393

You don't need GC to eschew manual memory management, though.
>>
>>54651561
>now piss off fag
First post source that a 15M LOC java project will have less bugs.
>>
>>54651573
yeah you sure stopped posting in /dpt/, we can clearly see that

>>54651583
that's not necessarily him, and anyway see >>54651053

it's a fucking trivial topic
>>
>>54651035
What exactly is this image measuring? Insert? Pushback? Iteration?
>>
>>54651460
nuh, it runs on a custom ui framework made by spotify. it's called spider or something like that
>>
Learned about interval trees, then figured out they could be used to store IP address ranges (not in CIDR notation, but actual start and end addresses). Spent hours hacking away and what I created was a thing of beauty. Inserted 2000 IP ranges into the tree and then brute-force checked all 2^32 IPv4 addresses just to see that it works. Yes, even the addresses that actually cannot be used. It worked beautifully, the whole test took about 2 minutes and after hours of checking and more testing, I didn't see a single failure. This was all in C++11.

Then I designed a way to store the tree on disk and only load the parts of it that are actually needed. Slower, but still quite fast.

Then I started to actually write the PHP script that needs to read that file and check if the visitor's IP address is in the tree. It didn't work, because PHP can't deal with unsigned integers and any IPv4 address that's 128. or bigger is a negative integer in PHP. So the tree didn't work, because the negative integers broke the comparison and wrong tree branches got selected. Back to the drawing board.

So then I split the one big tree into 256 smaller trees. I use the first octet to choose the tree, then use the remaining 24 bits to check if the address is in the tree. 24 bits won't overflow, so it actually works. PHP is too slow to check the all 2^32 addresses, but the C++ version works, so I believe the PHP version works too. I did check 100000 random addresses and it didn't fail even once.

Phew.

I hate PHP, but I don't have a choice.

I'd love to do this with IPv6, but the hosting service has no idea what that is, so it'd be a waste of time now. Maybe later.
>>
>>54651601
can't find any so I guess I won
>>
>>54651614
>that's not necessarily him,
I believe it is.

>and anyway see >>54651053
We already covered this, this relies on sizeof(int) being smaller than sizeof(int*) and it's fairly shitty solution to allocate more memory than you need.

>it's a fucking trivial topic
So is averaging two ints, but yet no one here is able to do it.
>>
>>54651628
lol wut
>>
>>54651637
you can use pointer arithmetic, the same as you would do with array access, so it doesn't matter what the sizeof(int*) is RETARD
>>
>>54651663
You can also just allocate a 1D array and access it doing arithmetics too, instead of storing both pointers and values in the same linear chunk of memory. I don't know why on earth you would think that was a good solution at all?
>>
File: i-won-bb.gif (489 KB, 450x224) Image search: [Google]
i-won-bb.gif
489 KB, 450x224
>>54651650
>>
>>54651709
>i can't find proof of what i claimed therefore i won
Sounds about right
>>
>>54651692
the retard insisted on having a dynamic memory contiguous 2d array so that it could be zeroed with one memset

either you use proper fucking 2d arrays FOR FUCK'S SAKE or you use a trick like that if you insist on having a malloced """"2d array"""" in contiguous memory
>>
>>54651725
>the retard insisted on having a dynamic memory contiguous 2d array so that it could be zeroed with one memset
No, he didn't.

All he said was that he had an array allocated as int** and asked how he could do it more efficiently than a nested for-loop. My first reply was "change it to a 1D array and do memset instead" and then you started going off like a retard crybaby about it works on 2D arrays too but not when you malloc and how 2D arrays are not 2D arrays after all and all sorts of retarded shit.
>>
>>54651692
also the int** solution with numerous different malloc'd memory also has extra memory for the pointers
>>
>>54651782
a dynamic memory array of arrays is not the same as a 2d array, 2d arrays work perfectly fine with memset
>>
>>54651800
Autism
>>
>>54651808
int **ptr;

pointer to pointer to int

int arr[m][n];

2d array

retard
>>
>>54651832
stop hurting me
>>
>>54651832
>if you create a 2D array in dynamic memory that's not the same as creating a 2D array because I'm trying to redefine arrays using my arbitrary definition so my original reply doesn't sound so stupid
>>
>>54651845
kill yourself idiot
>>
>>54651393
Automatic memory management is fit only for servers, where stuff will run for months and doesn't have to react to input in real time manner. Application software is the opposite of that, even a few leaks are fine if the UI does not stutter.
>>
>>54651851
lol, why are you getting so emotionally invested in this? Your answer is perfectly valid had the original anon allocated the array that way, but he clearly stated he hadn't, so why are you so upset over this and spend fucking 60 posts trying to say "oh, but you see, YOU are WRONG" instead of saying just "oh okay, then do this instead"

The autism displayed on this board never ceases to amaze me.
>>
>>54651875
>why are you getting so emotionally invested in this?
Because he's 12 years old

Now stop replying you fucking autist.
>>
>>54651875
my initial reply to >>54650728 (You) was perfectly reasonable, from the context provided there was nothing that mandated converting it to a 1d array, fucking retard

>>54650756
>>54650764
>>54650768
>>54650783
>>
>>54651515
Memset a 2d array? Like, "array of arrays" array? C doesn't have continuous 2d arrays so you'll have to use it in a loop, which defeats the whole purpose. When combined with allocation it's just one more line though.
>>
>>54651890
>from the context provided there was nothing that mandated converting it to a 1d array, fucking retard
>from the context
You were assuming that anon had created an array of contiguous memory. I were not. My suggestion would work in both cases, "fucking retard"
>>
>>54651895
even if you memset in a loop in a pig disgusting malloced array of arrays, it's still the same (or more efficient) as setting the values normally, there is no problem here

>>54651912
kill yourself, your answer was shitty and would lead to extra work and make his program shittier for no real reason, your post had caveats that you didn't explain
>>
>>54651393
>most of us aren't as smart
yeah, you're pretty dumb actually; leave C to the pros with big dicks
>>
>>54651912
>>54651890
Also, none of these are my posts anyway, so why list them?

>>54650756
>>54650764
>>54650768
>>54650783
>>
>>54651934
because they started the entire shitty debate, the fucking ridiculous claim that it was UB to memset a 2d array
>>
>>54651622
To check whether something is in a some kind of set, use the bloom filter. Isn't interval tree rather used for prefix sums?
>>
>>54651945
>it triggered my autism
Gotcha

Btw, memsetting an int** does in fact cause a memory leak.
>>
How would I go about finding location of string in a file? I know that given string exists in that file only once. So far I tought about reading n bytes, where n is the length of string, starting from offset 0 and iterating one by one untill you find that offset where that string is located.
>>
>>54651968
i was talking about an array, as implied by the variable name 'array', not an int**
>>
>>54651923
>your answer would lead to extra work and make his program shittier for no real reason
So would change his allocation to being stack allocated of fucking FIXED SIZE retard.

>inb4 VLA
Those are hardly implemented in C99 implementations, and it's only optional in standards after C99.
>>
>>54651972
https://en.wikipedia.org/wiki/String_searching_algorithm
http://stackoverflow.com/questions/3183582/what-is-the-fastest-substring-search-algorithm
>>
>>54651895
>C doesn't have continuous 2d arrays
you dumb, nigga? 2d arrays can only be continuos in C
>>
>>54651992
for most problems it's fine to have a fixed size array, you don't know what he's doing
>>
>>54651978
Are you seriously so retarded that you get confused if someone does this:
int** array;
?

>bawww it's not a real array
Except it is (can be, if you're going to be technical) due to pointer arithmetics, the only difference is how they are allocated.
>>
>>54651393
>Let's be honest: most of us aren't as smart as we think we are.
Speak for yourself.
>>
>>54652014
Some people write code more advanced than shitty fizzbuzzes, you know.
>>
>>54652020
you're wrong, for example an array can degrade into a pointer, but a pointer can't "degrade" into an array
>>
>>54651992
>hardly implemented
>what is gcc
>what is clang
>what is icc
anon...
>>
>>54652034
kill yourself retard
>>
>>54652004
They fucking aren't? They are one dimensional arrays of pointers. C# has real 2d arrays, as well as "array of array" arrays, they have different syntax and really are a continuous chunk of memory, not scattered around the heap.
>>
>>54652054
what is this then

int array[8][8];
>>
>>54652048
>icc
You need to compile as C++ in order to get it to work in icc, and as for gcc and clang they will spit out warnings.

>>54652051
That seems to be your go to reply when you are stumped. Let me remind you that you need to be 18 to post here.
>>
>>54652020
>Except it is
it isn't
>>54652039
arrays don't "degrade" into anything
>>
>go to /dpt/
>want to read comfy programming discussion
>70/88 posts are bait and calling each other names
why?
>>
>>54652051
>>54652064
>>54652039
>hurr durr all multi-dimensional array problems fit on the stack

You guys are retarded.
>>
>>54652069
>Some people write code more advanced than shitty fizzbuzzes, you know.
yeah what a useful response, retard, sure got me stumped

kill yourself
>>
>>54652054
>They fucking aren't
they are tho, you don't know C
>continuous chunk of memory
just like in C
>>
>>54652082
auto array = new int[m][n];


>hurr durr
>>
>>54652069
>You need to compile as C++ in order to get it to work in icc
wrong
>and as for gcc and clang they will spit out warnings.
no, they won't
>>
>>54652092
Show me the code that produces a continuous 2d array on heap.
>>
>>54652112
not C
>>
>>54651035
what the hell are you talking about 2016? People have known about this since like 2008
>>
>>54652124
the original questioner included C++
>>
>>54652122
int (*x)[8][8] = malloc(sizeof(int) * 8 * 8);
>>
>>54652124
int (*array)[n] = malloc(sizeof(int[n][n]));
>>
>>54652115
>wrong
It's true

>no, they won't
It is when you don't specify C99, turn on -pedantic and see for yourself
>>
>>54652074
>70/88
I see what you did there, /pol/lack scum
>>
C is shit
>>
>>54652176
this
>>
>>54652048
what is
>msvc
>tcc
>picoc
>...

There's a reason why it was reverted to optional in without assumptions about the implementation.
>>
>its another retard thinks arrays and pointers are the same thing episode
>>
>>54652158
>It's true
it's not
>when you don't specify C99
are you a retard that uses C89/C90 and complains about C99 features? ok
>>
>>54652207
>are you a retard that uses C89/C90 and complains about C99 features?
You do know that the default standard chosen by clang and gcc is not C99, right?
>>
>>54652158
GCC and clang use a variant of C99 by default since forever.
>>
>>54652205
No one ITT thinks so you fucking autismo.

Believing that there is only one way to implement a 2D array is retarded.
>>
So I'm coding the start of a program I'm making
It has a loop that runs at X times per second (defined in a settings file)
It's in C++
So to get it to run X amount of times per second, I used:
clock()
and Sleep() from Windows.h
I continued coding because it FELT like it was working perfectly
ANYWAY... I ran it at 60 loops per second for 36000 loops (60loops*60seconds*10minutes)
Using time stamps at the start of the program and end, I worked out it ran for 9:25 instead of the planned 10:00
SO what do I use instead to sleep for micro or even nano seconds????
I don't think nanosleep() is an option because I'm coding on Windows with Visual Studio
>>
>>54652204
>msvc
not a C compiler
>tcc
supports VLAs
>picoc
not a C99 implementation
>>
>>54652215
>>54652214
GCC uses C11 with GNU extensions by default since 5.1
>>
>>54652215
See >>54652214

Unless you specify C99 it will complain that VLAs are only supported in C99.
>>
>>54652229
any sensible programmer can distinguish between a true contiguous multi-dimensional array and an "array of arrays" or "jagged array"
>>
>>54652144
Array of arrays, the difference between row addresses should be 32.
http://ideone.com/tN4qF2
http://ideone.com/Imzu6Q
>>
>>54652245
>GCC uses C11 with GNU extensions by default since 5.1
And when you turn on -pedantic it complains.
>>
>>54652234
target a specific time stamps when you sleep, so if you sleep too much you sleep less next time etc
>>
>>54652214
GCC 5.1+: no warning
clang 3.0+: no warning
>>
>>54652238
>>54652245
VLAs are OPTIONAL (except in C99), get that through in your heads.

>>54652254
>"but they're not TRUE arrays"
Are you seriously using a no true scotsman about fucking arrays?
>>
>>54651965
Bloom filters don't work very well when you have multiple ranges of consecutive values, and you need to check if a certain value is inside any of those ranges. Not funny if some of the ranges have 2^24 values.

Interval tree stores the start and end values of every range in a binary tree structure.
>>
>>54652229
found the threads biggest idiot
>>
>>54652268
~/c/test$ gcc --version          
gcc (GCC) 6.1.1 20160501
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~/c/test$ gcc -c -pedantic test.c
~/c/test$ cat test.c
void f(int n) {
int x[n];
}
>>
>>54652249
you are wrong
>>
>>54652214
It's C11
>>
>>54652285
kill yourself idiot

any proper array (NOT JUST A FUCKING 2+ STAR POINTER) can be zeroed with one call to memset
>>
>>54652263
Don't blame me for your incorrect code.
>>
>>54652268
it doesn't tho, stop being retarded and test for yourself with a simple one liner, you shit
>>
Hey /dpt/, I'm used to clang and it's various idiosyncrasies. Are there any compelling reasons to switch to gcc?
>>
>>54651875
He's the same guy who says "kill yourself retarded sperg", "Cshart", and posts fedora images whenever someone talks about recursion.
>>
>>54652285
>VLAs are OPTIONAL
and the major implementations have opted to implement them
>>
>>54652307
gcc is probably the best general purpose C/C++ compiler and it has nice extensions you can use
>>
>>54652280
>clang 3.0+: no warning
>>
>>54652307
no
>>
>>54652305
Still wrong no matter how you turn it.
http://ideone.com/tN4qF2
>>
>>54652294
>>54652291
>>54652306
See >>54652331
>>
>>54651064
you're welcome
>>
>>54652344
Posting more incorrect code won't make it better.
>>
>>54652323
such as?
>>
>>54652309
Though apparently "Cmen" isn't a thing now that he's apparently taken a single class on it and can pretend he knows it. Remember, every language is horrible when you don't understand any of it!
>>
>>54652290
>>54652280

5 and 6 is relatively new, no? The default on most distros is still 4.something AFAIK.
>>
>>54652361
& is incorrect now? Unless you specify what's incorrect
>inb4 output
I'll consider you wrong.
>>
>>54652278
Thanks I'll give that a go now
>>
>>54652367
all kinds of attributes like optimization settings for specific functions, always-inline, noinline, noclone, various builtins

https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
>>
>>54652388
>Unless you specify what's incorrect
Your code has undefined behavior.
>>
>>54652383
>C tards
>>
>>54652386
>>54652290
>>54652280
>>54652331
>>
>>54652430
>4.8.4
>(c) 2013
Get out of here.
>>
File: clang.png (15 KB, 619x176) Image search: [Google]
clang.png
15 KB, 619x176
>>54652331
>>54652346
>>
>>54652430
>thinks 4.8 > 5.0

c-cucks everyone
>>
>>54652388
%d is the wrong format specifier for pointers.
>>
>>54652417
Again, checking variable's address is UB now? Show by which standard it is not defined. My point stands
>>
>>54652386
>The default
you're not a programmer, m8
>>
>>54652474
Using incorrect type specifiers in printf has undefined behavior.
>>
>>54652464
>>54652451
My point was all along that 5 and 6 are new, not many distros have them by default.

But nice memes.

>>54652459
Guess the Linux build of clang has different params than Xcode build
>>
>>54652467
%d is int, pointer is an unsigned int, this won't make a difference in what I was driving.
>>
>>54652474
>My point stands
if your point is that you're a fucking retard that doesn't know C, then yes
>>
>>54652474
It's apparently a fun game in this thread to say that someone's code has UB and spend half an hour teasing the reason before they actually cite the standard.
>>
>>54652496
>My point was all along that 5 and 6 are new,
Finally I see.
>>
>>54652490
Actually, most programmers downgrade their compiler to some ancient one when working on old projects. Or at least ancient standards.

nvcc won't play with gcc or clang unless it's the right (ancient) versions
>>
>>54652494
See >>54652506
*proving
>>54652508
Nice name calling. Step up, the point is still standing.
>>
>>54652519
It's not really a surprise that a bleeding edge compiler will use some C11-ish variant by default. I don't know what you tried to prove with that sentiment?
>>
>Using more than one line to create a class

#header .header-top {background: none repeat scroll 0 0 #000000;}


One-liners master race report!
>>
>>54652506
>%d is int, pointer is an unsigned int
That's also wrong. It's time to stop.
>>
File: gcc.png (17 KB, 611x184) Image search: [Google]
gcc.png
17 KB, 611x184
>>54652430
>>
>>54652544
lame bait
>>
>>54652559
Technically that's not undefined behaviour but implementation-defined.
>>
>>54652506
>pointer is an unsigned int
stick to css, lad, you have no fucking clue what you're talking about
>>
>>54652543
Is anything newer than 2013 bleeding edge? Apparently so since you're using a 2013 version as the benchmark.
>>
>>54652559
Just calling something wrong doesn't make it so. Cite sources, etc. My code shows that x[][] is continuous while that malloc shit isn't.
>>
>>54652568
>Technically
technically, you're an idiot, because the standard says it's undefined behavior
>>
>>54652574
>Is anything newer than 2013 bleeding edge? Apparently so since you're using a 2013 version as the benchmark.

In both cases I'm using the newest version of gcc that doesn't upset nvcc. It's an arbitrary benchmark, I'll give you that, but it's not one pulled out of a hat.
>>
technically you can all eat a dick
>>
>>54652585
>doesn't make it so
the standard calls it wrong; fuck off
>>
>>54652585
malloc will always return a contiguous block of memory.
>>
>>54652616
Meant to say version of gcc and clang
>>
>>54652616
I don't know what nvcc is. But gcc 5.1 which made gnu99 the default (or even a newer version) was released over a year ago.
>>
Python pleb here.
Making a program that starts with initializing a lot of variables... 280 variables, to be specific. The program won't run in Jupyter QtConsole though.
Wat do? How can I get the program to run even though it has all those variables
>>
>the point he is making is wrong because something completely unrelated is UB
Never change, /dpt/. Don't you wish you could program half as well as you can play C Standard Trivial Pursuit?
>>
>>54652631
It's the CUDA compiler (among other things). I had to downgrade clang and gcc in order to use it, and this is not very uncommon in many software projects.
>>
>>54652648
>The program won't run in Jupyter QtConsole though.
be more specific
>>
>>54652653
>I got BTFO
>>
>>54652657
When I try to click enter (which generally executes code in Jupyter), nothing happens. I find that I can't initialize that many variables at the same time, so I need a workaround.
>>
>>54652653
If you call others wrong and then continuously prove that you know very little about C, you'll get ridiculed. What did you expect?
>>
>>54652654
irrelevant
>>
>>54652663
I'm not him. I'm not even saying he's right, I haven't looked at the code, but none of you are proving he's wrong, either.
>>
>>54652681
Okay, so first the default compiler is irrelevant because it's not new enough, and then another example based on actual real-life use is irrelevant too?

What's relevant in your mind?
>>
>>54652679
Maybe you could use multiprocessing pool to initialize them?
>>
>>54652682
>I haven't looked at the code
then what the fuck are you talking about? it's obviously wrong so stfu
>>
I'm a self-taught begginner in C programming, and I have a little question:
How can my program know what's the host OS (for example if it's Linux or Windows, to know how to handle EOL characters properly)?
>>
>>54652716
The oldest compiler that defaults to a standard newer than C99
>>
>>54652728
So basically only the examples that proves your point is considered valid examples, while others are dismissed as "irrelevant"?
>>
>>54652663
me too thanks
>>
>>54652622
>>54652626
Just so you fucking shut up
http://ideone.com/tN4qF2
Difference is 0x100, should be 0x20
>>
>>54652737
fuck off turbo nigger you got btfo
>>
>>54652737
>as for gcc and clang they will spit out warnings
Is this statement correct?
>>
>>54652725
The relevant part is wrong because he used %d instead of %p?
>>
>>54652716
stop making bullshit claims next time or learn how to express yourself better, shitstain; don't make general claims about implementations when you actually mean to say "this specific old version that I'm forced to use in my shitty project"
>>54652069
>You need to compile as C++ in order to get it to work in icc, and as for gcc and clang they will spit out warnings.
>>
>>54652751
Like here
http://ideone.com/l0F9Ga
>>
>>54652398
Thanks. This is fantastic. The performance of naively replacing the compilers are really close, but maybe with some of these optimizations I'll see some improvement.
>>
>>54651429
Wasn't there a huge bug with the Linux scheduler that caused it to lag by up to 25% when operating on a database because it favored idling? I bet that cost servers a pretty penny, or maybe just a couple thousand dollars in wasted computation if they're really lucky.
>>
>>54652726
bump
>>
>>54652785
yes, that's how undefined behavior works, don't you know this?
>>
>>54652793
The keyword here is "was"
I don't think you'll find a bug-free java project.
>>
>>54652751
I'm sad to say that that, too, is undefined behavior. Let me show you mercy:
#include <stdio.h>
#include <malloc.h>

int main(void) {
int (*x)[8][8] = malloc(sizeof(int) * 8 * 8);
printf("%p %p\n", &x[0], &x[1]);
printf("0x%zx\n", sizeof(int) * 8 * 8);
}
>>
>>54652813
The behaviour would not even depend on endianness, much less output format, because the point is in the least significant byte. Anyway see the fixed version just for your autism.
>>
>>54652751
>undefined behavior
anon...
>>
File: 1463761477251.jpg (137 KB, 768x1024) Image search: [Google]
1463761477251.jpg
137 KB, 768x1024
What did he mean by this?
>>
>>54652826
Wow! Your own code proves you wrong even with "defined" behavior!
>>
>>54652786
>"this specific old version that I'm forced to use in my shitty project"
1) It's the default compiler in the long term stable version of Ubuntu

2) It's not my shitty project, try FUCKING EVERYONE WANTING TO DO CUDA DEVELOPMENT. Not just me, EVERYONE
>>
>>54652860
>still not showing the standard
Y-you too.
>>
File: indians.png (5 KB, 235x117) Image search: [Google]
indians.png
5 KB, 235x117
>/dsaaatdpttcst/ - Daily Shitpost and Argue About Trivial Details Pertaining to the C Standard Thread
>>
>>54652833
>would not even depend
so you don't know what undefined behavior means
>>
>>54652869
>1) It's the default compiler in the long term stable version of Ubuntu
Maybe you should have clarified that that version is the benchmark.
>>
>>54652780
Yes, unless you are using the newest versions.

See the images posted ITT.
>>
>>54652890
>Yes, unless it's not.
Please.
>>
>>54652862
Real Programmers <https://en.wikipedia.org/wiki/Real_Programmers> Don't use this shit.
>>
>>54652679
Maybe you could use multiprocessing pool to initialize them?
>>
>>54652890
>newest
define newest, backpedaling shitter!
>>
>>54652887
Go throw yourself under a buss. I never said this or that is "the benchmark", but that version of GCC is in far wider use than versions you have manually installed in order to get the cutting edge versions.
>>
>>54652862
She wants the Cog.
>>
>>54652862
Since we have Upotte and the tank girls one, why doesn't we have an anthropomorphized programming language cute-girls-doing-cute-things anime?
>>
>>54652920
>as for gcc and clang they will spit out warnings
please, stop fagging; you got told, deal with it in private
>>
>>54652819
The scheduler lag bug went unfixed for a decade. You haven't posted any comparably terrible bug.
>>
>>54652915
>>54652904
>define newest, backpedaling shitter!
Versions newer than the one bundled with the latest versions of your distro of choice.
>>
>>54652880
>I need to see where the standard says out of bounds access is undefined behavior
something tells me you're too dumb to read
>>
>>54652941
The newest version of clang does spit out warnings though.
>>
>>54652945
Sounds like an odd definition. Why not simply use the latest stable release?
>>
>>54652955
Show where it's out of bounds then. Remember, continuous arrays.
>>
So oracle dont give a fuck about Java. I think about learning another language. Is Microsoft loves C#?
>>
>>54652969
You can use any definition, but it still doesn't change the fact that until recently the default C standard used by two state of the art compilers was C90.

And even that doesn't change the fact that variable length arrays are optional to implement.
>>
>>54652971
x[2]
>>
>>54652726
Can you guys stop arguing about the C Standard and be helpful please? Show me a method that doesn't involve UB to find out which OS my C program is being compiled on? Maybe a symbolic constant?
>>
Yall niggas discuss fundamentally wrong code.
http://ideone.com/b8WCNJ
>>
>>54652957
no, it doesn't
>>
>>54652997
Use one of the macros
>>
>>54652800
#ifdef _WIN32
//define something for Windows (32-bit and 64-bit, this part is common)
#ifdef _WIN64
//define something for Windows (64-bit only)
#endif
#elif __APPLE__
#include "TargetConditionals.h"
#if TARGET_IPHONE_SIMULATOR
// iOS Simulator
#elif TARGET_OS_IPHONE
// iOS device
#elif TARGET_OS_MAC
// Other kinds of Mac OS
#else
# error "Unknown Apple platform"
#endif
#elif __linux__
// linux
#elif __unix__ // all unices not caught above
// Unix
#elif defined(_POSIX_VERSION)
// POSIX
#else
# error "Unknown compiler"
#endif
>>
>>54652971
on line 6
>>
>>54652996
2 < 8.
>>
>>54652998
>compilation error
what am i supposed to be looking at
>>
>>54653018
Thanks.
>>
>>54653002
It does, see >>54652331


>inb4 you try to pass of your custom build with custom parameters of clang as "newest version"
>>
>>54653027
You don't know the difference between a two dimensional array and a pointer to a two dimensional array.
>>
>>54652998
>I don't understand this
maybe html is better for you
>>
>>54653027
you only have 1, not 8
>>
Friendly reminder that /g/ can't
>average two ints
>initialize a two dimensional array
>>
>>54653034
that's not the latest clang, you dumb shit
>>
>http://ideone.com/1mS5Pj

instead of int[y][x] it's like int[x][y], wtf were they thinking
>>
>>54653085
Fuck off you gay nigger
>>
>>54653114
>muh ass got rekt
applecuck...
>>
>>54653029
That malloc shit isn't even a 2d array.
>>
>>54653120
>memeposting on 4chan makes me correct
>>
>>54653034
700.1.81 < 3.8
>>
hello+%0D%0Aworld%0D%0Ahello%0D%0A%0D%0Atest

came from
 
hello
world
hello

test


is there a reference out there for translating these tags? This is POST data sent from my browser
Thread replies: 255
Thread images: 12

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.