Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
_3u10
on Aug 1, 2021
|
parent
|
context
|
favorite
| on:
Tree Shaking
C allows you to call functions by string...
C++ also allows it, but the function names are a bit harder to guess.
Banana699
on Aug 1, 2021
[–]
> C allows you to call functions by string
please elaborate
garaetjjte
on Aug 1, 2021
|
parent
|
next
[–]
Possibly OP meant dlopen/dlsym on itself? But that's a stretch, and not really language feature...
lights0123
on Aug 1, 2021
|
root
|
parent
|
next
[–]
And functions aren't guaranteed to be included in the binary unless you pass additional compiler flags with that strategy.
_3u10
on Aug 1, 2021
|
root
|
parent
|
next
[–]
Very few things are guaranteed in C. If you want to guarantee the function exists let the operating system look up the function names by string for you.
_3u10
on Aug 1, 2021
|
parent
|
prev
[–]
Create a string, look up the address of a function in the library. Assign the address to a function pointer, call it.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
C++ also allows it, but the function names are a bit harder to guess.