2 registered members (sleakz, AndrewAMD),
684
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: lite-C bug
[Re: pascalx]
#467823
09/03/17 13:30
09/03/17 13:30
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
This doesn't work in normal C either. (Whoops, yes it does.)
s.P = malloc(sizeof(int));
(C++) Visual Studio says... "a value of type "void *" cannot be assigned to an entity of type "int *"
Last edited by AndrewAMD; 09/04/17 16:41.
|
|
|
Re: lite-C bug
[Re: AndrewAMD]
#467824
09/03/17 13:57
09/03/17 13:57
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
This doesn't work in normal C either.
s.P = malloc(sizeof(int));
Visual Studio says... "a value of type "void *" cannot be assigned to an entity of type "int *" Sounds like you compiled with C++ compiler. C performs an implicit cast, whereas C++ requires an explicit cast for void* (static_cast<int*>) Compiles in C
#include <stdlib.h>
#include <stdio.h>
struct S
{
int* P;
};
int main()
{
struct S s;
s.P = malloc(sizeof(int));
*(s.P) = 1234; // Ok
s.P[0] = 1234; // Ok
int* p = s.P;
p[0] = 2345; // Ok
printf("%d", *(s.P));
free(s.P);
return 0;
}
Last edited by pascalx; 09/03/17 14:40.
|
|
|
Re: lite-C bug
[Re: pascalx]
#467826
09/03/17 14:28
09/03/17 14:28
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
Another Error. Or maybe just unsupported.
#define ARRAY_SIZE 10
int array1[10]; // Ok
int array2[ARRAY_SIZE]; // Ok
int array3[ARRAY_SIZE+1]; // Error
void main()
{
}
Last edited by pascalx; 09/03/17 14:40.
|
|
|
Re: lite-C bug
[Re: pascalx]
#467834
09/03/17 22:15
09/03/17 22:15
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
Honestly guys, what kind of sorcery is this...
void f1()
{
return 0; // compiles fine
}
int f2()
{
return; // compiles fine
}
And this
void f()
{
printf("A");
}
void f() // Ok
{
printf("B");
}
void run()
{
if(is(FIRSTRUN))
{
f(); // prints "B"
}
}
Last edited by pascalx; 09/03/17 22:21.
|
|
|
Re: lite-C bug
[Re: pascalx]
#467835
09/04/17 00:16
09/04/17 00:16
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
void main()
{
const int i = 5;
i = 6; // Ok
printf("%d", i); // 6
}
|
|
|
Re: lite-C bug
[Re: pascalx]
#467856
09/04/17 18:07
09/04/17 18:07
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
Welcome to Lite C!!! In the following example, CASE1 is incorrect and CASE2 is correct syntax.
//#define CASE1
#define CASE2
int main()
{
vars b[3];
var c[3] = { 1.1, 1.2, 1.3 }; vars c1 = c;
var d[3] = { 2.1, 2.2, 2.3 }; vars d1 = d;
var e[3] = { 3.1, 3.2, 3.3 }; vars e1 = e;
b[0] = c1;
b[1] = d1;
b[2] = e1;
d[2] += 10.;
e1[1] += 20.;
int i, j;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
#ifdef CASE1
printf("%.2f ", b[i][j]); //dimension of array error
#endif
#ifdef CASE2
vars f;
f = b[i];
printf("%.2f ", f[j]); //this works!
#endif
}
printf("\n");
}
return 0;
}
|
|
|
Re: lite-C bug
[Re: AndrewAMD]
#467858
09/04/17 18:10
09/04/17 18:10
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
(b[i])[j] also works, if I remember correctly.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: lite-C bug
[Re: WretchedSid]
#467859
09/04/17 18:18
09/04/17 18:18
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
(b[i])[j] also works, if I remember correctly. Can confirm CASE3 works. Thanks for the tip!
//#define CASE1
//#define CASE2
#define CASE3
int main()
{
vars b[3];
var c[3] = { 1.1, 1.2, 1.3 }; vars c1 = c;
var d[3] = { 2.1, 2.2, 2.3 }; vars d1 = d;
var e[3] = { 3.1, 3.2, 3.3 }; vars e1 = e;
b[0] = c1;
b[1] = d1;
b[2] = e1;
d[2] += 10.;
e1[1] += 20.;
int i, j;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
#ifdef CASE1
printf("%.2f ", b[i][j]); //dimension of array error
#endif
#ifdef CASE2
vars f;
f = b[i];
printf("%.2f ", f[j]); //this works!
#endif
#ifdef CASE3
printf("%.2f ", (b[i])[j]); //this works!
#endif
}
printf("\n");
}
return 0;
}
|
|
|
Re: lite-C bug
[Re: AndrewAMD]
#467861
09/04/17 18:51
09/04/17 18:51
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
Welcome to Lite C!!! http://www.zorro-trader.com/manual/en/cscript_intro.htmThe disadvantage of a script is obviously that you have to learn the script language. Most products using strategy scripts require that you dive deeply into programming. No so with Zorro: lite-C is arguably the world's easiest serious programming language. It 'hides' almost all the programming stuff and allows you to concentrate on plain strategy. You can learn the lite-C essentials in about one day. I think the emphasis here is on "arguably" I don't understand how offering a limited subset of features is better than offering the whole package. I rather take the whole thing even if I don't need all of it. But it's ok. The upcoming Zorro DLL will solve a lot of headache.
Last edited by pascalx; 09/04/17 18:55.
|
|
|
Re: lite-C bug
[Re: pascalx]
#467863
09/04/17 19:33
09/04/17 19:33
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Because a broken subset of C is much easier to implement as a compiler. Why not use a LLVM/Clang as a compiler backend? Because they didn't exist back in 1423 when Lite-C was invented. But really, it's because with LLVM/Clang we would have never had the drama of the Chinese freelancer that bailed halfway through implementing the compiler leaving JCL with a bunch of Chinese comments and a voodoo black magic compiler.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: lite-C bug
[Re: WretchedSid]
#467864
09/04/17 19:57
09/04/17 19:57
|
Joined: Aug 2017
Posts: 58
pascalx
OP
Junior Member
|
OP
Junior Member
Joined: Aug 2017
Posts: 58
|
|
|
|
Re: lite-C bug
[Re: pascalx]
#468746
10/15/17 15:35
10/15/17 15:35
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
They probably have all constants in the data section, therefore this is possible on this compiler lol. Take a look at the generated assembly.
Last edited by Ch40zzC0d3r; 10/15/17 15:36.
|
|
|
Re: lite-C bug
[Re: Ch40zzC0d3r]
#468747
10/15/17 16:00
10/15/17 16:00
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
you can also write any statements outside of function definitions:
#include <acknex.h>
int i, j, k;
i = 10;
j = 20;
k = i + j;
printf("i=%d", i);
function main()
{
}
Nothing will happen, the compiler won't even emit a warning Fun Fact: You can implement generic functions with the behaviour that you can take the address of a constant:
void _list_add(void * list, void * obj, int size);
#define list_add(list, obj) _list_add(list, &obj, sizeof(obj))
...
list_add(myList, 10);
list_add(myList, 20);
|
|
|
|