R
Rick C. Hodgin
Is there a way to link object files between Visual C++ and GCC?
I have some data that I need to encode like this:
char* list[] = {
"one",
"two",
"three",
};
Unfortunately, by default, the list[0], list[1], and list[2] pointers point
to data that's in read-only memory. Any attempt to do something like
memcpy(list[0], "eno", 3) fails with "Access Violation" on Windows.
So, I discovered this syntax in GCC which creates the elements in read-write
memory, allowing memcpy(list[0], "eno", 3) to work properly:
char* list[] = {
(char []) { "one" },
(char []) { "two" },
(char []) { "three" },
};
I need the data pointed to by those list elements to be read-write in my
application. I can use this compound literal syntax in GCC to create
them in read-write memory, and it works in GCC. However, Visual C++
does not support this compound literal syntax and generates about 5
errors per line when I attempt it.
I was wondering if there's a way to link in that one file, which will
contain nothing more than a list like this sample, but with about 100
separate elements in it representing a source code file I need to
modify somewhat at use (replacing placeholders like "[9999]" with the
actual runtime observed values, such as "[ 1]" and so on), to my
Visual C++ generated code in Visual Studio 2008?
I'm looking for something like this:
gcc -c my_list.c
cl /c my_prog.cpp
link my_list.o my_prog.obj my_prog.exe
Thank you in advance.
Best regards,
Rick C. Hodgin
I have some data that I need to encode like this:
char* list[] = {
"one",
"two",
"three",
};
Unfortunately, by default, the list[0], list[1], and list[2] pointers point
to data that's in read-only memory. Any attempt to do something like
memcpy(list[0], "eno", 3) fails with "Access Violation" on Windows.
So, I discovered this syntax in GCC which creates the elements in read-write
memory, allowing memcpy(list[0], "eno", 3) to work properly:
char* list[] = {
(char []) { "one" },
(char []) { "two" },
(char []) { "three" },
};
I need the data pointed to by those list elements to be read-write in my
application. I can use this compound literal syntax in GCC to create
them in read-write memory, and it works in GCC. However, Visual C++
does not support this compound literal syntax and generates about 5
errors per line when I attempt it.
I was wondering if there's a way to link in that one file, which will
contain nothing more than a list like this sample, but with about 100
separate elements in it representing a source code file I need to
modify somewhat at use (replacing placeholders like "[9999]" with the
actual runtime observed values, such as "[ 1]" and so on), to my
Visual C++ generated code in Visual Studio 2008?
I'm looking for something like this:
gcc -c my_list.c
cl /c my_prog.cpp
link my_list.o my_prog.obj my_prog.exe
Thank you in advance.
Best regards,
Rick C. Hodgin