How to translate C headers contain gcc __attribute__?

General FreeBASIC programming questions.
marcov
Posts: 3004
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby marcov » May 02, 2020 20:28

systemctl wrote:
marcov wrote:
If you don't understand a post, please don't judge.


Stop being a parrot and repeat and repeat these boring words again and again. I understand, but I don't like it. Problem?


I don't like taxes either. Doesn't make them anything less real.
Last edited by marcov on May 03, 2020 12:03, edited 1 time in total.
caseih
Posts: 1518
Joined: Feb 26, 2007 5:32

Re: How to translate C headers contain gcc __attribute__?

Postby caseih » May 02, 2020 23:37

systemctl wrote:I wonder why FreeBASIC doesn't include headers for such an important library like OpenSSL, though. Could it be because lack of manpower?
FB only has headers for libraries when contributors provide them. I think maybe two people did the majority of the .bi files that are currently shipped with FB, and they did it for fun mainly, certainly not for any kind of reward. The number of people contributing to and developing the compiler itself is just a few. FB is a remarkable project and labor of love by those gentlemen. But it will always be undermanned and underfunded.
TeeEmCee
Posts: 298
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: How to translate C headers contain gcc __attribute__?

Postby TeeEmCee » May 04, 2020 1:40

You should just remove the #include for sys/queue.h from the Kore headers unless it's actually needed in the header itself. I doubt anyway would want to use those list macros in FB, they should use some native FB list/queue library instead. I don't think they should be part of FB's crt include files.

systemctl wrote:Stop being a parrot and repeat and repeat these boring words again and again. I understand, but I don't like it. Problem?


marcov wasn't wrong, you misunderstood his point. It's not about the flexibility of the preprocessor, but that a sequence of C tokens ("arbitrary partial C code") doesn't necessarily have an equivalent set of FB tokens.
C and FB are so similar that you can translate the tokens one-to-one in most cases, but the troubles generally involve 'for', '{' and '}'.

But I don't want to discourage you either, this is good work. And through your thread on Lib Ulfius I learnt about GNU Libmicrohttpd. Great! I think I will use that library for something.
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby TJF » May 09, 2020 19:29

TeeEmCee wrote:I think I will use that library for something.
Why should anybody use this?
Serving http-files can get done by any server (ie. Apache, nginx, lighttpd). And if you need a special connection to any FB code, you can add an fcgi-module.
I cannot find any sense in translating these headers.
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: How to translate C headers contain gcc __attribute__?

Postby systemctl » May 10, 2020 13:39

TJF wrote:
TeeEmCee wrote:I think I will use that library for something.
Why should anybody use this?
Serving http-files can get done by any server (ie. Apache, nginx, lighttpd). And if you need a special connection to any FB code, you can add an fcgi-module.
I cannot find any sense in translating these headers.


I want to have something equivalent to Free Pascal's brookframework or at least weblaz. I can't write such thing myself so the only thing I can do is translating from C library.
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby TJF » May 10, 2020 14:18

systemctl wrote:I want to have something equivalent to Free Pascal's brookframework or at least weblaz. I can't write such thing myself so the only thing I can do is translating from C library.

brookframework seems to be a library for creating a server. Why developing a custom server when we can use existing solutions (like apache, nginx, ligttpd)?

weblaz seems to be a library to create fcgi modules. Why not using the existing libfcgi solution (#INCLUDE ONCE "fastcgi/fcgi_stdio.bi")?

We have already better solutions. Why wasting time to translate that headers?
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: How to translate C headers contain gcc __attribute__?

Postby systemctl » May 10, 2020 14:46

TJF wrote:
systemctl wrote:I want to have something equivalent to Free Pascal's brookframework or at least weblaz. I can't write such thing myself so the only thing I can do is translating from C library.

brookframework seems to be a library for creating a server. Why developing a custom server when we can use existing solutions (like apache, nginx, ligttpd)?

weblaz seems to be a library to create fcgi modules. Why not using the existing libfcgi solution (#INCLUDE ONCE "fastcgi/fcgi_stdio.bi")?

We have already better solutions. Why wasting time to translate that headers?


I think you are misunderstood. Ulfius is a web framework. The web server backend is GNU libmicrohttpd.

HTTP Framework for REST Applications in C.

Based on GNU Libmicrohttpd for the backend web server, Jansson for the json manipulation library, and Libcurl for the http/smtp client API.

Used to facilitate creation of web applications in C programs with a small memory footprint, as in embedded systems applications.

You can create webservices in HTTP or HTTPS mode, stream data, or implement server websockets.


It's much, much more than cgi alone.

https://github.com/babelouest/ulfius
TeeEmCee
Posts: 298
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: How to translate C headers contain gcc __attribute__?

Postby TeeEmCee » May 10, 2020 15:16

TJF wrote:Serving http-files can get done by any server (ie. Apache, nginx, lighttpd). And if you need a special connection to any FB code, you can add an fcgi-module.


libmicrohttpd isn't attempting to compete with Apache, etc, it's for embedding inside applications.
I'm interested in embedding a tiny HTTP server inside a program for RPC basically; to interface with a (dynamically generated) webpage running in a web browser on the same machine. Specifically, a debugger for a script interpreter - the debugger then runs as a separate process, and I can write it using HTML/CSS/JS instead of needing to add some GUI framework.
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby TJF » May 10, 2020 17:10

TeeEmCee wrote:... to interface with a (dynamically generated) webpage running in a web browser on the same machine. Specifically, a debugger for a script interpreter - the debugger then runs as a separate process, and I can write it using HTML/CSS/JS instead of needing to add some GUI framework.
And why do you think you should create your own server?

Serv the standard pages (Intro, Parameters, Help, ...) by any existing standard server. And create only the dynamically generated part by an fcgi module, invoked by the standard server. You need not care about all that boring standard stuff (protocols, encryption, error handling, ...), but can focus on your real issues.

Do whatever you like, good luck!
systemctl
Posts: 182
Joined: Mar 27, 2020 5:15

Re: How to translate C headers contain gcc __attribute__?

Postby systemctl » May 10, 2020 17:55

TJF wrote:
TeeEmCee wrote:... to interface with a (dynamically generated) webpage running in a web browser on the same machine. Specifically, a debugger for a script interpreter - the debugger then runs as a separate process, and I can write it using HTML/CSS/JS instead of needing to add some GUI framework.
And why do you think you should create your own server?

Serv the standard pages (Intro, Parameters, Help, ...) by any existing standard server. And create only the dynamically generated part by an fcgi module, invoked by the standard server. You need not care about all that boring standard stuff (protocols, encryption, error handling, ...), but can focus on your real issues.

Do whatever you like, good luck!


Oh, my hero, don't be too harsh! You and D.J.Peters are my heroes. But this time you misunderstodd library Ulfius' purposes. It's designed for embedded environments (embeded hardwares, to be clear, something with very few resources that full standard web server like Apache, NginX can't work). C is not the language for web development. But porting web frameworks from other languages is too trickery so it left me with C only, and C web frameworks mostly, if not all, target embedded environments. Because no one would use C to do web development on a standard web server! Let's be clear.
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby TJF » May 11, 2020 5:20

systemctl wrote:It's designed for embedded environments (embeded hardwares, to be clear, something with very few resources that full standard web server like Apache, NginX can't work)
Yes, I second that. Does FreeBASIC compile for such embeded hardwares (ie. ESP8266)?
TeeEmCee
Posts: 298
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: How to translate C headers contain gcc __attribute__?

Postby TeeEmCee » May 11, 2020 6:07

I have an ESP8266; I should try.

TJF wrote:Serv the standard pages (Intro, Parameters, Help, ...) by any existing standard server. And create only the dynamically generated part by an fcgi module, invoked by the standard server. You need not care about all that boring standard stuff (protocols, encryption, error handling, ...), but can focus on your real issues.


Right, you don't need features like HTTPS for serving locally. Heck, you can even use HTTP/1.0. I don't want to ship some large full-blown server alongside a small application. Features like HTTPS support in libmicrohttpd are compile-time switches. A simple HTTP server of the sort I'm imagining can be implemented in as little as a few hundred lines of code; I've seen FB code for that purpose and that length, but I agree, it's less of a headache to use a more complete, mature server, like libmicrohttpd (although needing to use the embedding API creates extra work compared to using mod_fcgi).
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby TJF » May 11, 2020 6:57

TeeEmCee wrote:I have an ESP8266; I should try.
I thought about that, but dropped that idea. FB is a language with more than 400 keywords. Far too much for a 256 kB setting (ESP8266-1, half of the memory left for the user). Ie. you'll have to drop all grafic features. But you've to add WiFi features. You'll end up with a new language, which you have to document.

Is this worth the effort?

Sorry for being off topic.
marcov
Posts: 3004
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby marcov » May 11, 2020 7:18

TJF wrote:
TeeEmCee wrote:I have an ESP8266; I should try.
I thought about that, but dropped that idea. FB is a language with more than 400 keywords. Far too much for a 256 kB setting (ESP8266-1, half of the memory left for the user). Ie. you'll have to drop all grafic features. But you've to add WiFi features. You'll end up with a new language, which you have to document.

Is this worth the effort?


Depends on your needs. Not all keywords will be used at the same time, and not all draw in huge runtimes. But yes, you'll probably have to program directly for the micro, and not just "recompile and run".

If you however just want to toggle some outputs/relais, pwm a led, and get settings via wifi, that might be doable.

Sorry for being off topic.


Ditto
TJF
Posts: 3599
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: How to translate C headers contain gcc __attribute__?

Postby TJF » May 11, 2020 7:25

marcov wrote:If you however just want to toggle some outputs/relais, pwm a led, and get settings via wifi, that might be doable
Sure, it's doable. And already realized.

Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests