Not sure if this is strictly a code problem but since it flags one of my functions I trying here 1st, admin can always move the thread if it's deemed unrelated. So I finally settled on how I want my abstracted character reading object to be like and in turn modified all my related test projects to use a shared library, only the library in question is not completing the build process, here's the output:
Code:
make expr.run (in directory: /media/lee/ZXUIJI_1TB/github/mc)
cc -shared -Wall -D OUT=libnext.so -o libnext.so next.c
makefile:67: recipe for target 'libnext.so' failed
/usr/bin/ld: /tmp/ccsjP35t.o: relocation R_X86_64_PC32 against symbol `nextc_validate' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [libnext.so] Error 1
Compilation failed.
And the entire header:
Code:
#ifndef INC_NEXT_H
#define INC_NEXT_H
#include "fail.h"
#ifdef _WIN32
#include <windows.h>
#else
#include <limits.h>
#include <inttypes.h>
#include <stdbool.h>
#include <ctype.h>
#include <string.h>
#include <wchar.h>
#include <uchar.h>
#include <iconv.h>
#include <locale.h>
#endif
#define _2STR( DATA ) #DATA
#define TOSTR( DATA ) _2STR( DATA )
#define _2WCS( DATA ) L#DATA
#define TOWCS( DATA ) _2WCS( DATA )
#define _2UTF8( DATA ) u8#DATA
#define TOUTF8( DATA ) _2UTF8( DATA )
#define _2UTF16( DATA ) u#DATA
#define TOUTF16( DATA ) _2UTF16( DATA )
#define _2UTF32( DATA ) U#DATA
#define TOUTF32( DATA ) _2UTF32( DATA )
#ifndef __char8_t_defined
#define __char8_t_defined
typedef uint_least8_t char8_t;
#endif
#ifndef CHAR8_MAX
#define CHAR8_MAX UINT_LEAST8_MAX
#endif
#ifndef CHAR16_MAX
#define CHAR16_MAX UINT_LEAST16_MAX
#endif
#ifndef CHAR32_MAX
#define CHAR32_MAX UINT_LEAST32_MAX
#endif
typedef int (*func_nextchr )(
void * pointer, char8_t *c, size_t size );
/**
* @brief allocates/deallocates memory
* if size == 0, then if applicable pointer should be released
* else if pointer == NULL allocate the memory
* else reallocate the memory with new size
**/
typedef int (*func_moremem )( void **pointer, size_t size );
/**
* @brief appends next string/characters to ctxt
* @return 0 on success, ERANGE if not enough memory
**/
typedef int (*func_nextstr )(
void * pointer, char8_t *c, size_t *leng, size_t size );
/** @brief initialise with {0}
* @param err readonly, takes the exit code of the nextchr() parameter
* @param p readonly, nextc() function will fill this with the value of c
* @param c readonly, nextc() function will clear this before calling the nextchr()
* parameter
* @param src the source data nextchr() will take
* @param nextchr() fills c parameter, returns relevant exit code
**/
#define NEXTC_C_LENG 7
#define NEXTC_C_SIZE (NEXTC_C_LENG * sizeof(char8_t))
typedef struct _nextc {
int err;
char8_t p[NEXTC_C_SIZE], c[NEXTC_C_SIZE];
void *src;
func_nextchr nextchr;
} NEXTC;
/** @brief initialise with {0}
* @param err readonly, takes the exit code of the nextstr() parameter or moremem() parameter
* @param p readonly, nexts() function will fill this with the value of c
* @param c readonly, nexts() function will clear this before calling the nextstr()
* parameter
* @param src the source data working with, e.g FILE pointer
* @param moremem
* @param nexts() fills c parameter, returns relevant exit code
**/
#define NEXTS_INC_TXTLENG (NEXTC_C_LENG * 80)
#define NEXTS_INC_TXTSIZE (NEXTS_INC_TXTLENG * sizeof(char8_t))
typedef struct _nexts {
int err;
size_t size;
size_t plen, clen;
char8_t *ptxt, *ctxt;
void *src;
func_moremem moremem;
func_nextstr nextstr;
} NEXTS;
/** @brief Insensitive string compare with support for limiting
* characters
* @return returns 0 on equal or toupper(*a) - toupper(*b) when not equal
* @example istrncmp( NULL, NULL, 0 ), istrncmp( "a", NULL, 0 ),
* istrncmp( NULL, "b", 0 ), istrncmp( "a", "b", 2 ) are all possible
**/
int utfncmp( char8_t const *a, char8_t const *b, size_t limit );
int iutfncmp( char8_t const *a, char8_t const *b, size_t limit );
int nextc_validate( NEXTC *_nextc );
int nexts_validate( NEXTS *_nexts );
/** @return 0 = end of data or ignorable failure, 1 = success **/
bool nextc( NEXTC *_nextc );
/** @brief Loads next string from source
* @return 0 = end of data or ignorable failure, 1 = success
* @example nexts( &_nexts ); free( _nexts.ptxt ); free( _nexts.ctxt ); **/
bool nexts( NEXTS *_nexts );
#endif /* INC_NEXT_H */
Any ideas on why it's flagging that one function?