Author Topic: linker error  (Read 3562 times)

0 Members and 1 Guest are viewing this topic.

Emil_halim

  • Guest
linker error
« on: January 31, 2014, 09:39:14 AM »
Hi Charles,

i was playing with test example in C_code

here is my code
Code: [Select]

includepath "$inc\"
$ filename "test.exe"
#include "RTL32.inc"
#include "MinWin.inc"

includepath ""
#preprocess      // allow C-style preprocessing
#include c.inc

typedef struct
{
 float x;
 float y;
}Point;

float hypo(float x,float y)
{
 return sqr( x * x + y * y );
}

int f(int n)
{
 return n;
}

int main()
{
 int i;
 int q=4;
 Point p<={3,4};
 float r;
 r=hypo(p.x, p.y);
 for (i=0; i<10; i++)
 {
   if (q==7) ++q;
   q++
 }
 print (q); //result 15
 return 0;
}

main


when compiling i get that error
Quote
Linker found unidentified names:
ExitProcess:  level 0
GetExitCodeProcess:  level 0
getModuleHandle:  level 0

also when putting #preprocess  in c.inc file i got unidentified #preprocess ?

any help please.

Charles Pegge

  • Guest
Re: linker error
« Reply #1 on: January 31, 2014, 10:17:17 AM »
Hi Emil, I don't have your c.inc.

Place #preprocess at the top.

Couldn't quite cope with raw C, but I might be able to fix this in future releases. (around the for() statement.)

Code: [Select]
#preprocess      // allow C-style preprocessing

includepath "$inc\"
$ filename "test.exe"
#include "RTL32.inc"
#include "MinWin.inc"

includepath ""
'#include c.inc

typedef struct
{
 float x;
 float y;
}Point;

float hypo(float x,float y)
{
 return sqr( x * x + y * y );
}

int f(int n)
{
 return n;
}

int main()
{
 int i;
 int q=4;
 Point p<={3,4};
 float r;
 r=hypo(p.x, p.y);
 for i=0; i<10; i++ // ( )
 {
   if (q==7) {++q};  // { }
   q++
 }
 print (q); //result 15
 return 0;
}

main

Emil_halim

  • Guest
Re: linker error
« Reply #2 on: January 31, 2014, 10:22:37 AM »
Hi Charles,

here is the c.inc

Code: [Select]

#case sensitive
#indexbase 0
#unique on
#autodim off
'#noinit
#semicolon separator
#assign on

it 's old oxygen basic file

Charles Pegge

  • Guest
Re: linker error
« Reply #3 on: January 31, 2014, 10:33:53 AM »

Good! That works now without the the bracket alterations.

#semicolon separator was required.

Peter

  • Guest
Re: linker error
« Reply #4 on: January 31, 2014, 11:05:15 AM »
Better would be we had an OxyC and oBasic stays untouched.

Emil_halim

  • Guest
Re: linker error
« Reply #5 on: January 31, 2014, 11:09:43 AM »

okay , works fine now.

thank you Charles.

Hi Peter

what is wrong with extending Oxygenbasic to deal with c code? 

Emil_halim

  • Guest
Re: linker error
« Reply #6 on: January 31, 2014, 11:39:42 AM »
H Charles,

just i have a question , the #preprocess directive will allow OxygenBasic to deal with c_style PreProcess.

so if we are in some code that belong to basic code block and temporarily we disable C_style PreProcess ,
how to make that.

i think you can add On/Of parameter for #preprocess directive.

what do you think?


Charles Pegge

  • Guest
Re: linker error
« Reply #7 on: January 31, 2014, 12:02:22 PM »

I though about this issue for some time. It would cause too many complications. But there is a fair compromise:

macro and def are not handled by the preprocessor, so they can be deployed wherever localised/scoped macros are required, instead of #define or % or $.

JRS

  • Guest
Re: linker error
« Reply #8 on: January 31, 2014, 12:02:59 PM »
Quote
Better would be we had an OxyC and oBasic stays untouched.

Preventing change is like holding your breath. You can do neither for long.


Emil_halim

  • Guest
Re: linker error
« Reply #9 on: January 31, 2014, 12:08:29 PM »

I though about this issue for some time. It would cause too many complications. But there is a fair compromise:

macro and def are not handled by the preprocessor, so they can be deployed wherever localised/scoped macros are required, instead of #define or % or $.

yes , it very good solution , so at any time we can use "Def" & "Macro" as usual.

thanks you very much.

Emil_halim

  • Guest
Re: linker error
« Reply #10 on: January 31, 2014, 12:20:42 PM »
Hi Charles,

Oxygen basic compile this c code "part from zip library" without any error.
Code: [Select]
/* adler32.c -- compute the Adler-32 checksum of a data stream
 * Copyright (C) 1995-2003 Mark Adler
 * For conditions of distribution and use, see copyright notice in zlib.h
 */

/* @(#) $Id: adler32.c,v 1.1 2005/12/04 10:16:16 irrlicht Exp $ */

#define ZLIB_INTERNAL
#include "zlib.h"

#define BASE 65521UL    /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */

#define DO1(buf,i)  {s1 += buf[i]; s2 += s1;}
#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
#define DO16(buf)   DO8(buf,0); DO8(buf,8);

#ifdef NO_DIVIDE
#define MOD(a) \
    do { \
        if (a >= (BASE << 16)) a -= (BASE << 16); \
        if (a >= (BASE << 15)) a -= (BASE << 15); \
        if (a >= (BASE << 14)) a -= (BASE << 14); \
        if (a >= (BASE << 13)) a -= (BASE << 13); \
        if (a >= (BASE << 12)) a -= (BASE << 12); \
        if (a >= (BASE << 11)) a -= (BASE << 11); \
        if (a >= (BASE << 10)) a -= (BASE << 10); \
        if (a >= (BASE << 9)) a -= (BASE << 9); \
        if (a >= (BASE << 8)) a -= (BASE << 8); \
        if (a >= (BASE << 7)) a -= (BASE << 7); \
        if (a >= (BASE << 6)) a -= (BASE << 6); \
        if (a >= (BASE << 5)) a -= (BASE << 5); \
        if (a >= (BASE << 4)) a -= (BASE << 4); \
        if (a >= (BASE << 3)) a -= (BASE << 3); \
        if (a >= (BASE << 2)) a -= (BASE << 2); \
        if (a >= (BASE << 1)) a -= (BASE << 1); \
        if (a >= BASE) a -= BASE; \
    } while (0)
#else
  #define MOD(a) a %= BASE
#endif

/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
    uLong adler;
    const Bytef *buf;
    uInt len;
{
    unsigned long s1 = adler & 0xffff;
    unsigned long s2 = (adler >> 16) & 0xffff;
    int k;

    if (buf == Z_NULL) return 1L;

    while (len > 0) {
        k = len < NMAX ? (int)len : NMAX;
        len -= k;
        while (k >= 16) {
            DO16(buf);
            buf += 16;
            k -= 16;
        }
        if (k != 0) do {
            s1 += *buf++;
            s2 += s1;
        } while (--k);
        MOD(s1);
        MOD(s2);
    }
    return (s2 << 16) | s1;
}

 

so does Oxygen supports old c function parameters?
i mean this
Code: [Select]
uLong ZEXPORT adler32(adler, buf, len)
    uLong adler;
    const Bytef *buf;
    uInt len;
{
   

Charles Pegge

  • Guest
Re: linker error
« Reply #11 on: January 31, 2014, 12:35:05 PM »
Curly-Brace languages are very popular, so I thought we might benefit from some of their notation. :)

I advise caution when diving straight into this kind of code. Much testing remains to be done!

I have posted another update, with some fixes relevant to C: (about 4 hours ago)

http://www.oxygenbasic.org/forum/index.php?topic=749.0

Emil_halim

  • Guest
Re: linker error
« Reply #12 on: February 01, 2014, 09:05:50 AM »
Hi Charles,

after updating , some c source code need stdio.h and i found it in inc/glo2 folder.

so why you do not put it in the root inc folder?

Charles Pegge

  • Guest
Re: linker error
« Reply #13 on: February 01, 2014, 09:50:24 AM »
There are a few dummy files stored in /inc/glo2 to allow gl.h to be used directly, without editing.