Search found 9281 matches

by fxm
Dec 07, 2019 19:19
Forum: General
Topic: Preprocessor question
Replies: 16
Views: 355

Re: Preprocessor question

In Programmer's Guide / Preprocessor / Macros, paragraph "Macros debug", the method (using the "-pp" compiler option) to debug codes that use macros is described.
by fxm
Dec 07, 2019 18:51
Forum: General
Topic: Preprocessor question
Replies: 16
Views: 355

Re: Preprocessor question

If you look at the file.bas after preprocessing, you can see that everything is predisposed at compile time. file.pp.bas: dim as long k do locate 5 print "Press 1 = double" print "Press 2 = single" print "Press 3 = integer" print "Press 4 = string" print print...
by fxm
Dec 07, 2019 14:08
Forum: General
Topic: Checking if an array is empty.
Replies: 5
Views: 155

Re: Checking if an array is empty.

Or now, for fbc version >= 1.07: #macro GetSize(array,d) #include once "fbc-int/array.bi" #if __FB_VERSION__ >= "1.08" d = FBC.ArrayDescriptorPtr(array())->size #elseif __FB_VERSION__ >= "1.07" d = fb_ArrayGetDesc(array())->size #endif #endmacro
by fxm
Dec 06, 2019 18:43
Forum: General
Topic: Checking if an array is empty.
Replies: 5
Views: 155

Re: Checking if an array is empty.

OK for point 1 KeyPgUbound → fxm [corrected the erroneous comment in the fourth example] For point 2 If the array is not empty and if the index value 0 is not within the valid limits of the array, we get: - a compilation error for a static array, - or a runtime error for a dynamic array, when testi...
by fxm
Dec 06, 2019 16:16
Forum: General
Topic: Preprocessor question
Replies: 16
Views: 355

Re: Preprocessor question

Well done.

I still have trouble remembering the order in which macro calls must be nested for expressions to be correctly evaluated.
by fxm
Dec 04, 2019 5:59
Forum: General
Topic: (Solved) How to sort datasheet (x-dim array) by a few columns (at once in 1 loop) ?
Replies: 23
Views: 794

Re: How to sort datasheet (x-dim array) by a few columns (at once in 1 loop) ?

The Type structure contains only an array of string descriptors, and qsort only works on these to sort the list (string character data is dynamically allocated elsewhere in memory). Only your callback function access in read to the string character data when comparing the elements pointed by qsort. ...
by fxm
Dec 03, 2019 21:01
Forum: General
Topic: c qsort compare callback as member function?
Replies: 14
Views: 414

Re: c qsort compare callback as member function?

Thank you dodicat for your example. Your code slightly modified to manage a non-static member callback function (but virtual): extern "c" declare sub qsort_s alias "qsort_s"(as any ptr,as long,as long,as function cdecl(as any ptr,as any ptr,as any ptr) as long,as any ptr) end ext...
by fxm
Dec 03, 2019 20:13
Forum: General
Topic: c qsort compare callback as member function?
Replies: 14
Views: 414

Re: c qsort compare callback as member function?

I did not propose an example with qsort_s because I do not know how to get it back with FreeBASIC (Windows).

[edit]
But see dodicat's example below.
by fxm
Dec 03, 2019 17:22
Forum: General
Topic: c qsort compare callback as member function?
Replies: 14
Views: 414

Re: c qsort compare callback as member function?

Therefore, the principle using either 'qsort' or 'qsort_s' would be similar to the following example with either callback/[member_]launch or callback_context/[member_]launch_context: Sub launch (Byval psub As Sub(Byref str1 As String, Byref str2 As String)) psub("parameter #1.1", "par...
by fxm
Dec 03, 2019 14:08
Forum: Libraries
Topic: Missing Include Library
Replies: 7
Views: 375

Re: Missing Include Library

Look at page Compiler Option: -l -l < libname > is the command to add the library libname to the linker's list: - where '-l' is only a prefix to add a library file, - and 'libname' is the user name of the library. The internal name of the static library becomes 'lib < libname> .a...
by fxm
Dec 03, 2019 12:50
Forum: Beginners
Topic: 0-255 number to byte output
Replies: 2
Views: 96

Re: 0-255 number to byte output

For example:

Code: Select all

#include "file.bi"

dim as integer i
open "test.dat" for binary access write as #1
for i = 1 to 100
put #1, , cubyte(int(rnd * 256))
next i
close #1

print filelen("test.dat")

sleep
by fxm
Dec 03, 2019 9:12
Forum: General
Topic: c qsort compare callback as member function?
Replies: 14
Views: 414

Re: c qsort compare callback as member function?

Yes. A very twisted hacking could be to use a non-static member function as callback, but a function declared with a single explicit parameter: - thus, the implicit (first) parameter 'this' would correspond to the first pointer value provided by qsort, - and the only explicit (second) parameter woul...
by fxm
Dec 02, 2019 23:07
Forum: General
Topic: c qsort compare callback as member function?
Replies: 14
Views: 414

Re: c qsort compare callback as member function?

I vaguely remember this now from some other code. But I will probably forget again within a few months. All this is well described on the documentation page 'STATIC (Member)' . And qSortCallback() needs to be static because the compiler needs to know where the function code in memor...

Go to advanced search