shithub: docs.9front.org

Download patch

ref: 85b81a8a5802d56f60a77e2477a019f0792fe1fb
parent: 60b95550c1069b88c2334c53c995e16811c61dc1
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Mar 3 06:30:05 EST 2021

porting: add more information

--- a/porting.md
+++ b/porting.md
@@ -28,6 +28,21 @@
 
 ## Common issues
 
+Before trying to run anything, check the pragmas.
+
+	g pragma
+
+`#pragma pack(push)` and `#pragma pack(pop)` have to be replaced with
+`#pragma pack on` and `#pragma pack off`.
+
+`#pragma once` isn't supported either and, unless the project builds
+fine, the header's contents with the pragma have to be enclosed in:
+
+	#ifndef _header_name_h_
+	#define _header_name_h_
+	....
+	#endif
+
 ### function not declared: ...
 
 If the function defined in the project, and has no arguments, make
@@ -35,9 +50,10 @@
 
 ### alloca
 
-`alloca` allocates memory on stack, so that freeing it isn't required.
-Plan 9 does not have that.  It has to be replaced with `malloc` and
-`free` call before leaving the function.
+`alloca` allocates memory on stack, so that freeing isn't required.
+Plan 9 does not have that.  It has to be replaced with `malloc`.
+`free` call HAS to be added, before leaving the function, or else you
+WILL have memory leaks.
 
 ### *_MAX or *_MIN not declared
 
@@ -45,5 +61,21 @@
 
 	g UCHAR_MAX /sys/include/ape
 
-In most of the cases you can just add it to `src/plan9/plan9.h`.  Be
+In most of the cases, you can just add it to `src/plan9/plan9.h`.  Be
 careful if the size depends on the CPU you're targetting.
+
+### Some weird stuff with types/signatures not matching during linking
+
+This is probably caused by the compiler getting confused with forward
+declarations of certain types.  One object file seems to have one
+type, the other object file has a slightly different type with the
+same name.  Your best bet is to check the functions that error report
+is about.  One thing that has been found to help with cases like this
+(in case you're *sure* the types are correct):
+
+	#ifdef __plan9__
+	#pragma incomplete struct my_cool_struct
+	#endif
+
+placed after the type declaration.  It will tell the compiler not to
+bother too much.