**** BEGIN LOGGING AT Thu Apr 6 10:09:21 2023
Apr 06 10:09:21 * Now talking on #fpc
Apr 06 10:09:21 * Topic for #fpc is: Official channel for users and/or developers of the Free Pascal Compiler | https://gitlab.com/freepascal.org | Lazarus https://www.lazarus-ide.org | For code pastes please use https://pastebin.mozilla.org or http://paste.debian.net | Other channels -> #lazarus & #pascal https://wiki.freepascal.org/Operating_Systems_written_in_FPC https://www.onlinegdb.com/online_pascal_compiler
Apr 06 10:09:21 * Topic for #fpc set by Joanna!uid57472@id-57472.lymington.irccloud.com (Sun Jan 29 01:05:45 2023)
Apr 06 10:09:21 -ChanServ- [#fpc] Welcome to #fpc channel. If you have not spoken recently please introduce yourself and talk about how you discovered fpc
Apr 06 10:09:21 * Channel #fpc url: http://www.freepascal.org
Apr 06 10:17:48 <kroon> Hi. Using fpc, I'm trying to manually specify the mangled name for a function, "function foobar(x : integer) : integer", using "external name"-syntax. But even when declaring it with "external name 'V2STD_$$_FOOBAR$SMALLINT$$SMALLINT'" in other units, I still get undefined reference when linking.
Apr 06 10:18:12 <kroon> Is that not the correct mangling in the external declaration ?
Apr 06 10:18:34 <kroon> (V2STD is the name of the unit the function is declared in)
Apr 06 10:23:47 <kroon> Using 'nm' to inspect the .o file I can see that symbol is indeed in the text section
Apr 06 10:24:13 * zaher (~zaher@37.48.189.116) has joined
Apr 06 10:24:13 * ChanServ gives voice to zaher
Apr 06 10:25:25 <nickysn> kroon, 'nm' on which .o file? The unit that exports the symbol or the module (program/unit) where you import it?
Apr 06 10:25:37 <kroon> the unit that exports it
Apr 06 10:26:31 <kroon> if I use "public name '_foobar'" where I declare it, and then use "external name '_foobar'" where I reference it, it all links
Apr 06 10:27:05 <kroon> But when I leave out "public name", and try to use the fpc mangling scheme, I can't get it right for some reason
Apr 06 10:29:00 <nickysn> why not use it on both .o files (the one that exports it and the one that imports it) and see what's the difference?
Apr 06 10:34:23 <kroon> ok, might be because the symbol is not being marked as global
Apr 06 10:35:18 <kroon> I guess because I havent listed the function in the interface section
Apr 06 10:37:22 <kroon> Yeah.. is there a fpc compiler switch to mark all symbols as public ?
Apr 06 10:42:03 * fpcfan (~Thunderbi@103.55.100.165) has joined
Apr 06 10:42:03 * ChanServ gives voice to fpcfan
Apr 06 11:25:35 <nickysn> kroon, not as far as I know. What's the use of such switch?
Apr 06 11:29:01 <nickysn> In general, what are you trying to achieve? We can probably suggest better solutions, if we know the problem itself, not just the way you imagine the solution to the problem.
Apr 06 11:32:46 <kroon> In general I am trying to convert an old code base of Pascal written for Pascal/MT+ compiler.
Apr 06 11:33:42 <kroon> This old dialect did not use "unit":s, so all symbols were global
Apr 06 11:34:34 <kroon> So the use of this compiler switch would be to ease transition from old dialects of Pascal to a more modern version.
Apr 06 11:37:03 <kroon> I already have working perl scripts that can do the conversion, but they involve tagging all public procedures/functions with the "external name"/"public name" information. I'd like to avoid at least the "public name" part.
Apr 06 11:54:19 <nickysn> I'm not sure if you can avoid it. Using mangled names probably leads to problems within the compiler. The "external name", "public name" feature is meant for interoperability with C modules, where you don't have pascal name mangling at all.
Apr 06 11:55:01 <nickysn> The best long term approach is probably to convert the code base to use units. But I don't know how much of an effort that is.
Apr 06 11:55:08 <nickysn> Depends on the size of the code base.
Apr 06 11:56:05 <nickysn> And while FPC in general supports mode switches for different Pascal dialects, I don't think there's any support for "Pascal/MT+".
Apr 06 11:56:37 <nickysn> So far there's Turbo Pascal, Delphi, Mac Pascal and ISO Pascal support.
Apr 06 11:57:20 * Joanna has quit (Quit: Connection closed for inactivity)
Apr 06 11:58:44 <nickysn> Can't you just make your Perl script create units, where every function and procedure is also in the interface part of the unit?
Apr 06 12:03:34 <kroon> yes, but the problem is there is a lot of cross-references inbetween the new units
Apr 06 12:03:54 <kroon> I think I would need to reorganise the code in order to split it into proper units
Apr 06 12:07:50 <nickysn> Another hacky option is to convert all modules to include files, all crammed in a single program.
Apr 06 12:21:01 * Joanna (uid57472@id-57472.lymington.irccloud.com) has joined
Apr 06 12:21:02 * ChanServ gives voice to Joanna
Apr 06 12:21:24 <kroon> scripting and putting the global functions/procedures in the "interface" section seems to work for now
Apr 06 12:22:24 <kroon> but yeah, concatenating everything or including them into one big file might be an alternative
Apr 06 12:28:47 <Joanna> Hi kroon I’m curious to see what that code looks like it sounds interesting
Apr 06 12:37:43 <kroon> Joanna, its not exciting I promise. its regular ISO 7185 Pascal, with added quirks
Apr 06 12:39:35 <Joanna> kroon: it is easier for us to help you if we can see code. Here is a good paste site https://pastebin.mozilla.org/
Apr 06 12:52:30 * de_jean_paca (~de_jean_p@user/de-jean-paca/x-8740358) has joined
Apr 06 12:52:30 * ChanServ gives voice to de_jean_paca
Apr 06 13:43:12 * paule32 has quit (Quit: Leaving)
Apr 06 14:11:01 * fpcfan has quit (Ping timeout: 276 seconds)
Apr 06 14:51:35 * ChanServ gives channel operator status to Joanna
Apr 06 14:52:55 * You have been kicked from #fpc by Joanna (sorry we dont allow lurking please come back when you have more quesions about fpc)
**** ENDING LOGGING AT Thu Apr 6 14:52:55 2023
**** BEGIN LOGGING AT Tue Apr 11 10:54:43 2023
Apr 11 10:54:43 * Now talking on #fpc
Apr 11 10:54:43 * Topic for #fpc is: Official channel for users and/or developers of the Free Pascal Compiler | https://gitlab.com/freepascal.org | Lazarus https://www.lazarus-ide.org | For code pastes please use https://pastebin.mozilla.org or http://paste.debian.net | Other channels -> #lazarus & #pascal https://wiki.freepascal.org/Operating_Systems_written_in_FPC https://www.onlinegdb.com/online_pascal_compiler
Apr 11 10:54:43 * Topic for #fpc set by Joanna!uid57472@id-57472.lymington.irccloud.com (Sun Jan 29 01:05:44 2023)
Apr 11 10:54:43 -ChanServ- [#fpc] Welcome to #fpc channel. If you have not spoken recently please introduce yourself and talk about how you discovered fpc
Apr 11 10:54:43 * Channel #fpc url: http://www.freepascal.org
Apr 11 10:54:43 <paule32> ClassName
Apr 11 10:54:46 <paule32> IS
Apr 11 10:54:47 <paule32> AS
Apr 11 10:55:22 <paule32> you can use Template Classes
Apr 11 10:55:24 <paule32> Generics
Apr 11 10:55:35 <paule32> but i know this only in C++
Apr 11 10:55:44 <paule32> but fpc support template classes
Apr 11 10:56:03 <kroon> Hi. Is there a flag that makes 'fpc' allow bitwise "&" operator, instead of only "and" ?
Apr 11 10:56:22 <paule32> 2 + 2 = 4
Apr 11 10:56:25 <paule32> :)
Apr 11 10:56:42 <paule32> 2 amd 2 := 4
Apr 11 10:56:46 <paweld> Joanna: https://paste.brudnopis.ovh/?4f50c4e0b9a3cd0b#8eNjJnTqhfZrNuJGfaH3pn5tVFRoGB8XkwqjT6gmfGNA
Apr 11 10:56:53 <Joanna> Thanks
Apr 11 10:57:25 <paweld> ClassName, as paule32 wrote
Apr 11 10:58:33 <Joanna> Yes I do that now but as I said it doesn’t work for base classes. It’s fine for simple controls
Apr 11 10:59:23 <paule32> if you subclass: class MyButton(TButton)
Apr 11 10:59:32 <paule32> then ClassName is MyButton
Apr 11 10:59:40 <paule32> and TButton is still Base
Apr 11 11:00:45 <paule32> in constructor (delphi mode) you can: inherited Create;
Apr 11 11:00:47 <Joanna> Im not sure what you mean
Apr 11 11:01:23 <Joanna> kroon: why do you need a bitwise & operator?
Apr 11 11:01:24 <paule32> as i see your problem, it comes in my mind, that you dont subclass the components
Apr 11 11:01:35 <paule32> by placeing it simply on the form
Apr 11 11:02:07 <paule32> kroon: code: asm mov eax, 42 end;
Apr 11 11:02:59 <paule32> kroon: code: asm and eax, 2 end;
Apr 11 11:04:10 <paule32> the above is for 32-bit
Apr 11 11:04:24 <paule32> for 64-bit x86 use rax
Apr 11 11:04:34 <Joanna> Maybe he got bored and went afk ...
Apr 11 11:04:55 <paule32> why ?
Apr 11 11:04:57 <kroon> Joanna, I have one Pascal compiler that allows "&" as a bitwise and operator. I'd like to compile the code with "fpc" without modifying the sources.
Apr 11 11:05:09 <Joanna> No idea :)
Apr 11 11:05:37 <paule32> & minds me on C/C++
Apr 11 11:05:41 <paule32> for references
Apr 11 11:06:06 <opDispatch> kroon, not there is not such a thing. Not same language family
Apr 11 11:06:13 <Joanna> Well I don’t know much about those sorts of things . Have you tried the forums
Apr 11 11:06:34 <paule32> Joanna: this are the basics !
Apr 11 11:06:47 <kroon> opDispatch, ok
Apr 11 11:06:57 <opDispatch> oh wait kroon
Apr 11 11:07:07 <Joanna> Kroon lets have a look at your code
Apr 11 11:07:16 <opDispatch> you have one Pascal compiler that allows "&" as a bitwise and operator. I'd like to compile the code with "fpc" without modifying the sources ?
Apr 11 11:07:29 <kroon> opDispatch, correct
Apr 11 11:07:30 <opDispatch> you've patched the compiler ?
Apr 11 11:07:46 <opDispatch> or is it another pascal dialect ?
Apr 11 11:08:00 <paule32> opDispatch: patch the compiler is not a good thing
Apr 11 11:08:11 <paule32> opDispatch: implementing is better, but ...
Apr 11 11:08:17 <opDispatch> okay so what dialect it is ?
Apr 11 11:08:38 <kroon> opDispatch, The sources are built with an old Pascal/MT+ compiler, that allowed "&" as bitwise operator. Now I am trying to build the sources with fpc
Apr 11 11:08:48 <opDispatch> okay thanks
Apr 11 11:09:57 <paule32> opDispatch: maybe it is a typo B, 8 ß ...
Apr 11 11:10:01 <paule32> kroon: https://wiki.freepascal.org/Operators
Apr 11 11:10:18 <opDispatch> one thing however... & is usefull when you also have &&. The double ampersand allows implicit conv to bool, the single ampersand form doesn't. That the point !
Apr 11 11:10:40 <opDispatch> "&" instead of "and" is not interesting otherwise, from my POV
Apr 11 11:11:42 <paule32> && is abbrevertive in C/C++ for Pascal AND
Apr 11 11:11:43 <opDispatch> so... translating that to Pascal... & is useful if you restrict "and" to bool ops.
Apr 11 11:12:56 <opDispatch> and then that opens the possibility to have implicit bool eval, e.g with pointers...
Apr 11 11:13:02 <Joanna> Pascal doesn’t use & for anything does it?
Apr 11 11:13:19 <opDispatch> indeed it does not
Apr 11 11:13:57 <opDispatch> THe problem of reusing and for both bool and bitwise ops is that you cannot have implicit bool eval
Apr 11 11:14:06 <paule32> http://ctp.mkprog.com/en/pascal/bitwise_and/
Apr 11 11:14:13 <opDispatch> you see ?
Apr 11 11:14:17 <Joanna> I guess he won’t be compiling with fpc unless he fixes his code
Apr 11 11:14:41 <paule32> under the old c/C++ there gave enitities for shorten some symbols
Apr 11 11:15:01 <paule32> but new c++ standards does not support this anymore
Apr 11 11:15:25 <Joanna> Kroon can we see your code ?
Apr 11 11:16:24 <kroon> Joanna, no
Apr 11 11:17:18 <paule32> maybe a german umlaut entity, when the codes come from a website, and the user / webserver does not display these in wrong style
Apr 11 11:17:19 <paule32> https://de.wikipedia.org/wiki/Hilfe:Sonderzeichenreferenz
Apr 11 11:17:25 <opDispatch> a && b => a != null && b!= null VS a & b => (size_t)a & (size_t) b. That distinction is not possible in objFPC because "and" is reused.
Apr 11 11:17:53 <opDispatch> so we have to type the full comparison.
Apr 11 11:18:23 <opDispatch> That's what two operators are intersting for.
Apr 11 11:18:25 <paule32> or a system command for a bash shell
Apr 11 11:18:48 <paule32> echo "hello: " && ./ls && echo "dodo"
Apr 11 11:19:30 <paule32> or a "Format" String: '\&...
Apr 11 11:20:12 <opDispatch> honestly I dont think objFPC will add implicit boolean evaluation because of that.
Apr 11 11:20:16 <Joanna> kroon: who are you in the forums?
Apr 11 11:20:32 <paule32> or a shellcode exploit :)
Apr 11 11:21:58 <kroon> Joanna, why do you want to know that ???
Apr 11 11:22:15 * ChanServ gives channel operator status to Joanna
Apr 11 11:22:39 <opDispatch> nowadays is just use helpers for class, like isAssigned and isNotAssigned to hide the fact that we have to explicitly compare : `if a.isAssigned() and b.isAssigned then ...;` Not as great as `if a and b then ... ,` but good compromise ;)
Apr 11 11:23:13 * Joanna sets ban on $a:kroon
Apr 11 11:23:14 <opDispatch> almost as good ;)
Apr 11 11:23:29 <paule32> that is no standard
Apr 11 11:23:40 * You have been kicked from #fpc by Joanna (please go get help in forums)
**** ENDING LOGGING AT Tue Apr 11 11:23:41 2023