written by xqtr of another droid bbs [andr01d.zapto.org:9999] BBSes, today are running in multiple platforms... windows, linux, rpi, os2, c64, macos etc. Writing mods/apps/doors for all of these systems it may be possible, but it's not easy. Someone could use a programming language that is supported by many of these systems and compile his program to each one. It may sound logical and easy, but it's not. Each system differs in small or even big things, that the programmer must have in mind to successfully compile his program. This text will only show some of the most common mistakes and its not, by any mean, an in depth analysis for cross compilation. Conditional Compilation The most important tool in your arsenal for cross compiling programs. You wont cross compile a thing, with out writing code which is unique for each system. For sure in a cc program, the 80% of code is usable in all systems, but you will have to write a 20%, which will be unique. To do this, we have to use conditional compiling. We write code for each system and let the compiler know with some flags/definitions. For example in FreePascal we can write something like this: {$IfDef Windows}  ..code here..  {$EndIf}  {$IfDef Linux}  ..code here.. {$EndIf} When the compiler reach the first IfDef, will check if is compiling in a Windows system. If so, then it will compile the code between that IfDef block. If the system is not Windows, it will bypass this block and go to the next one, which tell to the compiler to check if it's compiling in a Linux machine etc. So, we can write code, for each and every system we care about. Conditional compilation is a big chapter and each programming language implements it in a different way, so you have to learn about it. Path Delimiters The most common mistake a programmer does, is to use the exact path delimiter that his system uses, inside the code. For example in Linux the path delim. is '/' but in Windows is '\'. If we use the exact character in the code, then the program will not compile in both systems. Instead we should use a variable which will represent the path delim. char. depending the system we compile the program. For example in FreePascal such a variable is PathDelim from the SysUtils unit. So instead of writing:  mypath := currentfolder + '\' + filename; we should write:  mypath := currentfolder + pathdelim + filename; The first will compile only under Windows, but the second will compile under all systems that FPC has a compiler. Know the OS! You wont be able to cross compile if you don't have some knowledge of the system OS you are going to compile for. Each OS has its own characteristics, libraries, tools, structure etc. So you have to know about them. When you will learn them, you will be able to decide if you will use compiler directives/definitions or write code that is compatible with all systems or both. Its not advisable to always use compiler directives and in some cases you can't write the code with out using them. But to know this and make the wise decision, you must have some knowledge of the systems you are going to compile for. Some OSes use big or little endian format, the alignment for records, differs from system to system or the default signedness etc. Uppercase or Lowercase, Not Both! Basically this is the same as above, but because its a very common mistake it deserves to be mentioned separately. When you use files in a program and also use their file names inside your code, make sure that the case is the same. Don't include files with upper case filenames and refer to them, in your code, with lower case names. This will cause too much trouble in systems like Linux/MacOS/RPi. Prefer to use lower case filenames and stick to that guide, so you avoid trouble. Write once use many... When you write your code, make it in a way that its going to be easy to reuse it again and again. Make your own Units/Libraries of code that can cross compile and use them, instead of re-writing the same code over and over. Just make it simple and not over do it. Use standards Use standard tools, libraries, components etc. as you can. Don't customize your code with extra stuff that are not very usable. The case will be, that a custom applet/component/lib that is used in one system is not used in another. But if you use standard libraries from your programming language, you will have less problems cross compiling the code. Go slow and steady, to go faster... Don't try to write a program for a system and then port it to another. By doing so, you wont manage to simultaneously publish your code for all systems, but each port will have a delay. Also while porting the code to another system, perhaps you may "brake" the code. You will write code for one port that it may not be compatible with another and vice versa. Instead, write the code for a procedure/function and make sure that it compiles in all systems you want. Then proceed with another and so on. This way, you will be sure that your code inside your functions is working in all systems and the debugging process will be easier.  ,s. .  . `$' "s + ı s sı'  "s,. . ; , ,s$' ,sS$$Ss, ,sı ıs. ,s. úú - ----- `$s. --- -  ,ssS$$$$$$SsS$SssS$Sı""""ıS$$$$$$SıııııS$SSSSıııııSS.`$',S$$.`s.`$SıııS$SssSs. ;$$$$$$'.`ı$$$$$$$$',sS$$Ss,`S$S' + ." ı ı$',sS$$$Ss.`ı; $$ı',s$' ,s$$Ss.`$$$$$ ' `$$$$s s',S',ss.',$$$$$$$$Ss.s' sS$S',$.,S$$$$$$$$$Ss$s.,dS$$$$$$$$$$$$ $Sıı$ . ,$$$$$+`$s.$$$$$$$$$$$$$$S$$$$$SssssS$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$Sı', ;$;  $$$$Sı',S$$$$$$$$S$$$$$$$$$$$$$$$$$$$$$ıııı$$$$$$$$$$$$$$$$$$$$$$$$$$$$."ı' ',s $$Sı'."'ı$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ı ggg ^^ . ^^^^øøb$$$$$$$$$$$$$$$ı"+',$$$ $',s' s ,$$$$$$$$$$ı ,, ı aaa ı.,aaa,, $$$ee,o$b $$$eea,. ı$$$$$$$$$$',s.`$$$$ $.`ı', d$$$$$$$$$$$$$$ $$$ $$$'''$$$ %$$ `$$P $$$``$$$l $$$$$$$$$$.`ı',$Sı" $$S$$';$$$$$$$$$$$$`$$o.d$$' $$$---$$$ $$$------ $$$- -$$$ $$$$$$$$$$$S.`$$;  ',s.`s Y$$$$$$$$$$$a .oeee$o. $$$ ° $$$ $$$ °°... $$$ °° .. $$$$$$$$$$$$$ $$$Ss .`ı',$+ `$$$$$$$$$$$$$P-4$$$ `$$---$$$ $$$---.o$ $$$------ $$$$$$$$$ı"ı',$$$$$ $$$',ss+$$$$$$$$$$$$$$ n S$$p Y$" $$$ ^$$a.a$$'$$$ s$$$$$$$$$$$$$$.~ıs$$$$$$ $$$.`ı'. $$$$$$$$$$szzz$$$zzzz$szz. $$$szzzzzzzs8zzzz$$$$$$$$$$$$$$$Ss"+ S$Sı$ $$'bz`S',$$SıS$$$SıS$$$$$$$$$$$$$S$Szzz$$SıS$$ıS$$$$$$$$$SııS$$$$$$$',sSsS$' ,$ ;$SssS $$$$s .`ı$ Ss.`ıS$$$$Sı',ssssS$.`$',.`$. `ıS$$$Sı',SS.`$'.`ıS.`S$$$$sS$$  `ıS$$.`ııı',$',ı ı$$$Sssssss%S$$$$$$$$ ',$',ı',$SsssssS$ııS$ ; $$s.ı+`S$S$$Sı' (-------- -- úú"s' ú `ı$'  `ı$' , `S$' $ ,$. `ıSSSı' org:bz-basic.asc   ;  "s `ı' " s "' `ı'   ,$.  '   `ı'