Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #157554
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: I need help understand some c code |
| Date | 2020-12-20 22:10 -0800 |
| Organization | None to speak of |
| Message-ID | <874kkfbsfu.fsf@nosuchdomain.example.com> (permalink) |
| References | <rrp1gb$kle$1@dont-email.me> <rrp8ij$r14$1@dont-email.me> <87czz3bw39.fsf@nosuchdomain.example.com> <rrpapu$4mj$1@dont-email.me> |
T <T@invalid.invalid> writes:
> On 12/20/20 8:51 PM, Keith Thompson wrote:
>> T <T@invalid.invalid> writes:
>> [...]
>>> I need to cancel this question. I am making the
>>> mistake of calling a library in C (time.h) and what
>>> I really need is to call a function inside a
>>> /usr/lib64/libxxx.so.x. And I do not know what
>>> that is. (Google keeps pointing me back to time.h.).
>>>
>>> And since I am only look to create examples for a
>>> paper I am writing, I do not really care what
>>> example I use.
>>
>> This shows a serious lack of understanding about how C works, and
>> possibly compiled languages in general. I don't say this to be
>> insulting, but to suggest that you don't know enough to know what
>> questions you need to ask.
>>
>> time.h is a header, not a library. It provides an interface to
>> library code (in this case, the C standard library) by providing
>> type and function declarations. The code that implements those
>> functions may well be in /usr/lib64/libxxx.so.x on one system, or
>> in some completely different place on another. As a C programmer,
>> you very probably don't need to know. The compiler and/or linker
>> handles it all for you. If you know to write "#include <time.h>" at
>> the top of your C source file, that's probably all you need to know.
>>
>> If I write a simple program, say one that prints "hello world",
>> I create a source file, then I compile, link, and run it. On my
>> system:
>>
>> gcc hello.c -o hello
>> ./hello
>>
>> gcc, and the tools it invokes, take care of all the details for me.
>> 99% of the time I literally do not care where time.h or the library
>> that implements the time function exist on the system.
>>
>> Find yourself a decent C tutorial and follow it. There are
>> undoubtedly some decent ones online. Perhaps others can suggest one.
>> (There are a lot of really bad ones, and you don't yet know enough
>> to tell the difference.)
>>
>> Since you're apparently working on interfacing between C and another
>> language, you're likely to need more knowledge than you'd need just to
>> write and run C programs, but I suggest starting with that as a minimum.
>
> You misunderstand. NativeCall is calling a system
> interrupt. Native call does not calls to C libraries.
> That is why I need to call a function inside a .so.
I don't think "system interrupt" is an accurate representation of what
Raku's NativeCall does.
https://docs.raku.org/language/nativecall
Apparently it's used to call a function in a native library, with the
code implemented in *.dll on Windows or *.so on a Unix-like system.
Those library files will likely contain the implementation of the C
standard library, or of some other library. For example, on my system a
simple C "hello world" executable will load libc.so.6, which it will find
at /lib/x86_64-linux-gnu/libc.so.6, which is a symbolic link to
/lib/x86_64-linux-gnu/libc-2.31.so. All that is likely to be very
different in different implementations.
I fail to see what interrupts have to do with this.
> Maybe if I root around inside the c code that goes
> with time.h, I would be able to find that, but it
> is way over my head.
Reading the C code that implements the functions declared in <time.h>,
even if it didn't go over your head, is unlikely to help you with what
you're doing. The source code won't tell you how the code generated
from it is packaged into a library file.
Though you're interfacing to C functions, your questions are really
about linking (which is specific to an OS, not to a language) and Raku's
NativeCall interface. You're likely to get much better help in a forum
that deals with Raku. https://www.raku.org/community/ looks like a good
place to start. I think if you mention on the #raku IRC channel that
you're looking for help with NativeCall they can give you some good
pointers. (And anyone who's familiar with Raku and NativeCall is
likely to know about C as well.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I need help understand some c code T <T@invalid.invalid> - 2020-12-20 18:32 -0800
Re: I need help understand some c code Siri Cruise <chine.bleu@yahoo.com> - 2020-12-20 19:03 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 19:56 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 20:02 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 20:43 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 21:06 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 21:56 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 20:33 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 20:51 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 21:11 -0800
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-20 22:10 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-20 22:15 -0800
Re: I need help understand some c code Bart <bc@freeuk.com> - 2020-12-21 13:11 +0000
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-21 13:47 -0800
Re: I need help understand some c code scott@slp53.sl.home (Scott Lurndal) - 2020-12-23 17:18 +0000
Re: I need help understand some c code Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-12-23 12:05 -0800
Re: I need help understand some c code T <T@invalid.invalid> - 2020-12-21 14:25 -0800
Re: I need help understand some c code Bonita Montero <Bonita.Montero@gmail.com> - 2020-12-21 05:45 +0100
Re: I need help understand some c code Bart <bc@freeuk.com> - 2020-12-21 12:16 +0000
Re: I need help understand some c code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-12-21 20:03 +0000
csiph-web