/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_10.html
surfaceplotter.com/
swift.org/blog/dictionary-and-set-improvements/
twitter.com/SFWRedditImages

roll

from last thread
i have now following code in my makefile
CC = gcc
CFLAGS = -Wall -pedantic -std=iso9899:2011

foo: foo.o
$(CC) $(CFLAGS) foo.o -o foo

bar: bar.o
$(CC) $(CFLAGS) bar.o -o bar

foo.o: foo.c
$(CC) $(CFLAGS) -c foo.c

bar.o: bar.c
$(CC) $(CFLAGS) -c bar.c


but only foo gets an executable, for bar there is not even an object file created.
can anybody help?

Posting it again

Which book on compilers should I get?
I want some theory on parsers and lexers as well, no Yacc/Flex and ANTLR.
The classic Dragon Book, Engineering a Compiler by Cooper/Torczon or something else?

Nothing

all: foo bar

Or something like that

eww
fuck make satan

fuck opengl though

merci!

CC=gcc
CFLAGS=-Wall -pedantic -std=iso9899:2011
all: foo bar
foo: foo.o
bar: bar.o

that is all

>that is all
how does this magic happen?
that is neat

Encrypted communications network in Erlang

I am so hard

what c book would you commend?

No good make alternatives sadly

have anything to share lad?
sounds fun

The GNU C reference manual

scons

Sounds great. Would like to see something. I have to make an imitation models using OpenModelica.
And also have to comparce what tasks are easier to implement in Scala rather than Java. Have no idea.

The Go Programming Language. It's C evolved.

>install python in order to compile c
pls no

most linux based distros come with python preinstled tho

What the fuck are you using that doesnt have python be default

Employed Haskell programmer reporting in

I'll have a cheeseburger and a coke. Thanks!

Location? Only Haskell/Elixir jobs I can find are in shit valley

>his distro has bloat preinstalled

>he uses a """"distro""""

>installing make and shell in order to compile c
pls no

>not having shell, make and compiler in initramfs
c'mon

>how does this magic happen?
Read

ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_10.html

>Installing a compiler to write high level C instead of pure asm
pls no

>installing a bloated assembler instead of writing pure hex
lad...

>codemonkey shit instead of being a manager
JUST

nothing substantial yet but the info I can give is that it'll be a WebRTC peer maker using perfect forward secrecy that connects two peers and makes sure they both form a direct p2p socket to each other using a strong cipher suite.
Will post some code soon. From the little I know from Scala actor models are easier done in Scala than java.
>she doesnt create her own with musl + gcc + mksh

I've been working on an app in the last few months which plots implicit surfaces. It's working pretty well now.

surfaceplotter.com/

It uses the marching cubes algorithm to create the surface mesh, and I've implemented things like parallax mapping and triplanar mapping to texture the surface. How does it run for you?

>glorified baby sitter with no value or fulfillment in life anymore
friend...

There's no point in limiting your development environment.
Having python based build is good because you script it with actual scripting language.

protip: you don't need to """script it""", you just need to declare it

Many years ago i used to be good at delphi ( yes, i know), was starting to pick up C# but stopped leaning programming. I want to get back into it now but im on Linux, how's .net core on Linux? Also is golang good?

>.net core on Linux?
it's immature but generally fine, if you don't mind being locked into microsoft's build system
consider mono as an alternative

>implying people don't write 1000 line makefiles which end up including millions of bash scripts to build their shitty library

correct; people don't write 1000 line makefiles; they just cargo cult copy-paste someone else's autoconf script from the '70s

c++ will never be good, but a proper modules system would at least help stop every new file i have to create from coming with a creeping sense of dread and disgust, and i can't understand why they don't just do it already

design by committee

you should join the design committee, you obviously have this stuff figured out

I don't understand.

pretty good i would say

>>> import re
>>> penis = re.compile(r'([!]{2,})|([?]{2,})')
>>> asshole = penis.sub(
... lambda match : '!' if match.group( 0 )[ 0 ] == '!' else '?',
... 'Sup!!!! Easter??????'
... )
>>> asshole
'Sup! Easter?'

Or alternatively
>>> penis = re.compile(r'([!]{2,})|([?]{2,})')
>>> def replacer( match ):
... matched_substring = match.group( 0 )
... if matched_substring.startswith( '!' ):
... return '!'
... else:
... return '?'
...
>>> asshole = penis.sub(
... replacer,
... 'Sup!!!! Easter??????'
... )
>>> asshole
'Sup! Easter?'

Thanks. I wanted to do this without a loop or if/else statements, like within the first argument of the .sub method.

swift.org/blog/dictionary-and-set-improvements/
>emoji in code on the official blog
what did they mean by this

supports unicode
or whatever

Trying to understand bitwise operators

I'm given this function that's supposed to find the midpoint of low and high:
char mid_B(char low, char high)
{
return ((unsigned char)low + (unsigned char)high) >> 1;
}


I worked out that mid_B(-120, -10) should give me 63, but when I run it through gcc, it gives me -65 (the correct answer).

My question is: Despite initially casting both chars to "unsigned", gcc appears to fill the right-shift with ones on the left. Here's my work:

mid_B(-120, -10). /* Should be -65, but am worried about sign extension in signed chars */

-120 in binary = 1000 1000
-10 binary = 1111 0110
-----------
0111 1110

Right shifting the answer:
(Assuming unsigned right shift, we padd the left with zeroes):
0111 1110 >> 1
0011 1111 => 0x3f = 63

But I guess C adds a one to the front?

I'm dumb, this should work too:
asshole = penis.sub(
lambda match : match.group( 0 )[ 0 ],
'Sup!!!! Easter??????'
)

user who is trash at string manipulation here.
How do I go about making a loop that takes in a user inputted String, the user then tells me that they want to replace a single character in the String, and the program then finds that instance of the character and then replaces it with the character the user wants.

Example would be:
>"proggamming"
>replace 'g'
>second 'g' with 'r'

output: programming.

I have a for loop that allows me to replace all instances of a character but I can't exactly pinpoint how to replace a single instance without impacting the entire string.

I have an idea that I need to keep a variable that counts the instances of the character and I need to print out the new string based off of this data but I don't exactly know how to write that in java code.

It works, thanks.

who better c here?

Assuming you are representing a String as an array of characters

char[] user_function(char str_to_change[STR_LENGTH], char char_to_replace, char replacing_char, int location)
{
// declare an integer variable that keeps track of how many times you've
// seen "char_to_replace"

for(int ind = 0; ind < STR_LENGTH; ind++)
if(str_to_change [i] == char_to_replace)
if(location == {variable that's been keeping track of how many times you've seen a char })
str_to_change[i] = replacing_char
else
// increment counter

return str_to_change
}


You're on the right track

I'm actually confused... What's .the point of excluding #include if you're going to have packages anyway? Aren't they the same thing?

Or is it a really specific "Oh packages can let you take several functions but not the entire file " thing?

it may be an Obj-C-style #import instead, a little higher-level (didn't read it)

Header files are just included as is into the current file, that's why you usually use header guards.
I assume with those package you just write your C file but mark some functions public and you don't need separate header file.

See that's what i'd love to do but I can't use arrays in my assignment. I'm sure I can find a way to do that without arrays.

Should I pick up C++ again (my knowledge of it at this point is very rusty, I last used it about 10 years ago) or start with Rust?

Who cares, you are just going to shitpost on Sup Forums anyway.

>Also is golang good?
it's the only meme language in existence
the only reason people use it is that it's backed by Google (it does have a good concurrency model admittedly)

includes aren't namespaces

this hacking book is kinda outdated but it says you can use strcpy to overwrite the return value of a stack frame. does that still work?

I need some help with a compilation error I'm having:
Fraction.cpp:21:10: error: prototype for ‘Fraction Fraction::operator+(const Fraction&)’ does not match any in class ‘Fraction’
Fraction Fraction::operator + (const Fraction& toAdd) {
^~~~~~~~
Fraction.h:20:20: error: candidate is: const Fraction Fraction::operator+(const Fraction&)
friend ostream& operator

*not return value, i meant the saved pointer to the place where instruction flow should resume after the frame exits. not sure what to call it

If i'm doing separate object file compiling using g++ for example
$g++ -c -g -o foo.o foo.cpp
$g++ -c -g -o bar.o bar.cpp
$g++ -g -o foobar foo.o bar.o

if I want to change the foobar having -O3 flag instead of -g, then should I recompile all of the file with the new flag or I just need to run $g++ -O3 -o foobar foo.o bar.o
Notes: the foo.o and bar.o is compiled with -g flag

Just go to gen.lib.rus.ec and get all of them.

Writing a POSIX driver for the sel4 microkernel. I'll then create a distribution called gnu turd.

Forgot to include, function is called as such

while(fin >> fOne >> sign >> fTwo) {
if (sign == "+")
fOne + fTwo;
}

After upgrading the translator script for blender I realized I have a bunch of little tools that could be merged into a toolkit for Blender, so I've started working on a personal blender plugin for it.

So far, the toolkit will have:
-saving bone names to file
-saving material names mapped to blender to file
-mass remove constraints from IK

How do I convert all radians onto a 0-pi scale? I.e:

9.42477796077 = 3 * pi = pi

-3.92699081699 = -5pi/4 = 3pi/4

You need to recompile from scratch. When you call g++ on object files it just passes them to the linker.

(2pi + (theta % (2 pi))) % 2pi

Say, how many lines would you need to create a program that took a point, a slope, and a distance. then proceeded to draw a line with that slope and length with the point as origin?

From scratch.

>a slope
reported for racism

about tree fiddy

in C++ how to have a pointer of their child on parents class??
for example:
struct parent
{
protected:
child * chd;
public:
void setChild(child * in) {chd = in;}
};

struct child : public parent
{
public:
int val;
};

Its always saying that child has not been declared.

is there a way to do this with python?
perl -e 'print "A" x20;'

ie from bash give an inline command and have it output the result?

i'd need more than just lines, friendo

Best languages to actually get a job?

C#

The frame pointer. Yes, that attack would work against a poorly written function, assuming the information you can manipulate is on the stack, not the heap.

depends on the language and how you plan on drawing the line

Java

In order:
Java
Javascript
C#
Python
everything else

webdev = js/python/php/sql

general/enterprise software/backend=c#/java

simulations/engines/microprocessor=c/c++/asm

Haskell

use character pointers instead of arrays? input the string from the user into a character pointer, then run a for loop going round until you come across the characters you want. each time the loop goes ground add 1 to the pointer to bump up the memory address to the next character in the string?

char *p=0
p = gets();

while (*p) {
if(p=='g')
//change the character
else {
}
*(p++);
}

I use C# and I actually have a job.
I make good money.

my professor is autistic and has a full page of potential deductions if our code does not exactly adhere to his preferences. one of them is this:
>Nameable values not in const or constexpr (-5%)
what does this even mean

Runt brain: dynamic types
Small brain: simple or polymorphic types
Large brain: dependent types that are logical propositions
Ascended brain: dependent types that aren't logical propositions

Fixed
Python
Javascript
Java
C#
everything else

do u have a degree?

Yes.

means he wants you to properly label variables that should be const.

There you go then