473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Compiling Guppy-PE extension modules

I have been informed that Guppy-PE (http://guppy-pe.sourceforge.net)
has failed to compile its extension modules with a Microsoft .NET 2003
compiler under Windows 2000.

[To the person who informed me about this in an email per 27 Nov:
Thanks for your message.
I couldn't reply to you because your email address bounced my
mail.]

One of the problems, seems to be string constants in the C source that
contain newlines. I am using GCC on Linux so, I missed this with the
standard warning options. Compiling with -pedantic reveals 'a lot' of
places where this is a problem.

I could fix this but it takes some work and it makes the source code
less readable so I was wondering ...

Is this a common problem? Or maybe it is just the compiler version
mentioned that doesn't handle it?

Does someone know of some switch to enable the Microsoft compiler to
accept strings with newlines?

If so, the setup could perhaps be made to pass this switch to the
compiler when building under Windows.

Or else,..

somebody knows about a script to convert the files to the format the
Microsoft compiler wants? I guess the build compilation could then be
setup to pipe them through this or otherwise convert the files as
needed.

Otherwise, I guess I'll just have to hand-hack around this problem,
write a conversion script, or whatever. I will see.

Sorry for any inconvenience so far.

Regards,

Sverker Nilsson

PS. I know it's not ANSI-correct but why do we have to work to make
our source codes less clear?

Nov 29 '05 #1
7 1984

"Sverker Nilsson" <sv********@home.se> schrieb im Newsbeitrag
news:11**********************@z14g2000cwz.googlegr oups.com...
I have been informed that Guppy-PE (http://guppy-pe.sourceforge.net)
has failed to compile its extension modules with a Microsoft .NET 2003
compiler under Windows 2000.

[To the person who informed me about this in an email per 27 Nov:
Thanks for your message.
I couldn't reply to you because your email address bounced my
mail.]

One of the problems, seems to be string constants in the C source that
contain newlines. I am using GCC on Linux so, I missed this with the
standard warning options. Compiling with -pedantic reveals 'a lot' of
places where this is a problem.

I could fix this but it takes some work and it makes the source code
less readable so I was wondering ...

Is this a common problem? Or maybe it is just the compiler version
mentioned that doesn't handle it?

Does someone know of some switch to enable the Microsoft compiler to
accept strings with newlines?

If so, the setup could perhaps be made to pass this switch to the
compiler when building under Windows.

Or else,..

somebody knows about a script to convert the files to the format the
Microsoft compiler wants? I guess the build compilation could then be
setup to pipe them through this or otherwise convert the files as
needed.

Otherwise, I guess I'll just have to hand-hack around this problem,
write a conversion script, or whatever. I will see.

Sorry for any inconvenience so far.

Regards,

Sverker Nilsson

PS. I know it's not ANSI-correct but why do we have to work to make
our source codes less clear?


Thank you for posting to comp.lang.python .

Beside the problem with the multiline strings in sets.c I was getting also:

src\sets\sets.c(70) : error C2099: initializer is not a constant
src\sets\sets.c(71) : error C2099: initializer is not a constant
src\sets\sets.c(71) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(72) : error C2099: initializer is not a constant
src\sets\sets.c(72) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'int (__cdecl *)(PyObject *)'
src\sets\sets.c(72) : warning C4028: formal parameter 1 different from
declaration
error: command 'E:\VisualC++NET2003\Vc7\bin\cl.exe'
failed with exit status 2

Anyone here who succeeded to compile and use this module with
Python 2.4.2 on Windows 2000/XP? Please share your experience.

Claudio


Nov 29 '05 #2
On 29 Nov 2005 11:53:31 -0800 in comp.lang.python, "Sverker Nilsson"
<sv********@home.se> wrote:

[...]
One of the problems, seems to be string constants in the C source that
contain newlines. I am using GCC on Linux so, I missed this with the
I'm not sure what you mean by this. Something like

char long_string[] = " A long string that
extends to subsequent lines
before closing the quote? ";
standard warning options. Compiling with -pedantic reveals 'a lot' of
places where this is a problem.

I could fix this but it takes some work and it makes the source code
less readable so I was wondering ...
Eye of the beholder, I guess.

You were aware that C supports concatenation of string literals
separated only by whitespace? For example, if the problem is similar
to the long_string example above, and it does what I think it does,
the following code should be equivalent and will compile on any good C
compiler (even Microsoft's).

char long_string[] = " A long string that\n"
" extends to subsequent lines\n"
" before closing the quote? ";

Not that much worse, and you could probably write a Python script to
automate the changes. If a quote opens but doesn't close on a line,
append a newline and close the quote, then prepend an opening quote on
the next line. The only tricky part is making sure the opening quote
isn't inside a comment or character literal.

Is this a common problem? Or maybe it is just the compiler version
mentioned that doesn't handle it?
I wasn't even aware GCC supported such an extension. Certainly no
other C compiler I've used has anything like this.

Does someone know of some switch to enable the Microsoft compiler to
accept strings with newlines?
Not that I'm aware of. Sorry.

Maybe one exists, but if so, I'd resist the temptation to use it. It
might disappear in a later version of the compiler, or you might need
to use some other compiler that doesn't support multiline strings, and
you're back where you started.

[...]

PS. I know it's not ANSI-correct but why do we have to work to make
our source codes less clear?


Hysterical raisins. Regards,
-=Dave

--
Change is inevitable, progress is not.
Nov 29 '05 #3
"Claudio Grondi" <claudio.gro...@freenet.de> wrote:
Beside the problem with the multiline strings in sets.c I was getting also:

src\sets\sets.c(70) : error C2099: initializer is not a constant
src\sets\sets.c(71) : error C2099: initializer is not a constant
src\sets\sets.c(71) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(72) : error C2099: initializer is not a constant
src\sets\sets.c(72) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'int (__cdecl *)(PyObject *)'
src\sets\sets.c(72) : warning C4028: formal parameter 1 different from
declaration
error: command 'E:\VisualC++NET2003\Vc7\bin\cl.exe'
failed with exit status 2


Some of those messages are misleading, confused me at least. Seems
like a bug in the error reporting part of the compiler. Anyway, the
code was not ANSI and what I got around that place was:

sets.c:69: warning: ANSI forbids initialization between function
pointer and `void *'
sets.c:71: warning: ANSI forbids initialization between function
pointer and `void *'

There were a bunch of other problems too.

I have made a new version now, 0.1.1 .
It compiles cleanly with gcc -pedantic .

When looking in the code I became worried that there may be other
problems with Microsoft Windows since there is some magic with
DL_IMPORT that may be necessary and that I think I added most of the
time but I may have missed some. I have no easy way to test with
MSWindows currently and it will probably take a while before I get
around to do it.

The new version is on the home page:

http://guppy-pe.sourceforge.net

Regards,

Sverker

Dec 1 '05 #4
> I have made a new version now, 0.1.1 .
It compiles cleanly with gcc -pedantic .


but the problem with sets.c remains:

C:\VisualC++NET2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /G7 /GX
/DNDEBUG -IE:\Python24\include -IE:\Python24\PC /Tcsrc/sets/sets.c
/Fobuild\temp.win32-2.4\Re
lease\src/sets/sets.obj
sets.c
src\sets\sets.c(68) : error C2099: initializer is not a constant
src\sets\sets.c(68) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'NyHeapDef_SizeGetter'
src\sets\sets.c(69) : error C2099: initializer is not a constant
src\sets\sets.c(69) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(70) : error C2099: initializer is not a constant
src\sets\sets.c(70) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'int (__cdecl *)(PyObject *)'
src\sets\sets.c(70) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(70) : warning C4028: formal parameter 1 different from
declaration
error: command 'E:\VisualC++NET2003\Vc7\bin\cl.exe' failed with exit status
2

The MSDN help gives a simple example of code raising compiler error C2099:
// C2099.c
int j;
int *p;
j = *p; // C2099, *p is not a constant

The example code shows to me, that there is a good reason compiler
generates an error in that case.
j = *p; leads to an assignment of a random (and therefore maybe leading to a
non deterministic crash of the executable during runtime) value to a
variable, what can't be intended in a deterministic program.

Hope this helps.

Claudio
Dec 2 '05 #5
"Claudio Grondi" <claudio.gro...@freenet.de> wrote:
but the problem with sets.c remains:

C:\VisualC++NET2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /G7 /GX
/DNDEBUG -IE:\Python24\include -IE:\Python24\PC /Tcsrc/sets/sets.c
/Fobuild\temp.win32-2.4\Re
lease\src/sets/sets.obj
sets.c
src\sets\sets.c(68) : error C2099: initializer is not a constant
src\sets\sets.c(68) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'NyHeapDef_SizeGetter'
src\sets\sets.c(69) : error C2099: initializer is not a constant
src\sets\sets.c(69) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(70) : error C2099: initializer is not a constant
src\sets\sets.c(70) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'int (__cdecl *)(PyObject *)'
src\sets\sets.c(70) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(70) : warning C4028: formal parameter 1 different from
declaration
error: command 'E:\VisualC++NET2003\Vc7\bin\cl.exe' failed with exit status
2

The MSDN help gives a simple example of code raising compiler error C2099:
// C2099.c
int j;
int *p;
j = *p; // C2099, *p is not a constant

The example code shows to me, that there is a good reason compiler
generates an error in that case.
j = *p; leads to an assignment of a random (and therefore maybe leading to a
non deterministic crash of the executable during runtime) value to a
variable, what can't be intended in a deterministic program.


This is confusing, because the problem of the example code is not that
*p is not constant but rather that p is undefined aka uninitialized.

Humm..

Compiling the following program:

#include <stdio.h>
int main(void) {
int j;
int *p;
j = *p;
printf("%d\n",j); /* Makes sure the optimizer doesnt remove the
previous code */
return 0;
}

with

gcc -O3 -Wall main.c

gives me:

main.c: In function `main':
main.c:4: warning: `p' might be used uninitialized in this function

(And I get a Segmentation fault from running the executable.)

The -Wall flag enables, umm, as it is saying 'all' warnings
though perhaps not really all, and this flag + others is used
by the compilation command generated by distutils when
building with gcc.

I don't see any warnings when building Guppy.

So there should be no case (as easy to discover) as that in the
example.

So I am confused.

I was beginning to wonder if we were talking about the same file/code.
This code is from sets.c lines 66..71

static NyHeapDef nysets_heapdefs[] = {
{0, &NyMutBitSet_Type, (NyHeapDef_SizeGetter) mutbitset_indisize},
{0, &NyCplBitSet_Type, 0, cplbitset_traverse},
{0, &NyNodeSet_Type, nodeset_indisize, nodeset_traverse,
nodeset_relate},
{0}
};

I can't see how there can be problems with initializers not being
constants here unless, perhaps if the compiler has a problem since
those functions (mutbitset_indisize etc) and the types that are used
as initializers are in separately compiled files. But gcc -Wall
-pedantic handles it and doesn't warn. I don't have the ANSI standard
but I have the 2nd edition of The C Programming Language by Kernighan
and Ritchie (1988, 'Based on Draft-Proposed ANSI C'), and it is saying

- quotes -

A8.7 Initialization
....

All the expressions in the initializer for a static object or array
must be constant expressions as described in &A7.19
....

A7.19 Constant Expressions

Syntactically, a constant expression is an expression restricted to a
subset of operators...
....

More latitude is permitted for the constant expressions of
initializers... Initializers must evaluate either to a constant or to
the address of a previously declared external or static object plus or
minus a constant.

- end quotes -

If this means the Microsoft .NET compiler is perhaps not compliant
with standard/ANSI C then since it was from 2003 maybe they have come
out with an update now that fixes this problem. I know, it may not
really help you because it may cost money, I don't know how long one
can get updates without paying. Alternatively, I think GCC is
available for Microsoft Windows although I don't know how it handles
the .NET architecture.

For me, if the case is according to hypothesis, and I would have to
rewrite the code to put all the functions and type objects in a single
file, it would be.. umm.. painful. (Though I could get around
it with #include trickery but it is still painful.)

Sverker

Dec 2 '05 #6

"Sverker Nilsson" <sv********@home.se> schrieb im Newsbeitrag
news:11*********************@z14g2000cwz.googlegro ups.com...
"Claudio Grondi" <claudio.gro...@freenet.de> wrote:
but the problem with sets.c remains:

C:\VisualC++NET2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /G7 /GX
/DNDEBUG -IE:\Python24\include -IE:\Python24\PC /Tcsrc/sets/sets.c
/Fobuild\temp.win32-2.4\Re
lease\src/sets/sets.obj
sets.c
src\sets\sets.c(68) : error C2099: initializer is not a constant
src\sets\sets.c(68) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'NyHeapDef_SizeGetter'
src\sets\sets.c(69) : error C2099: initializer is not a constant
src\sets\sets.c(69) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(70) : error C2099: initializer is not a constant
src\sets\sets.c(70) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'int (__cdecl *)(PyObject *)'
src\sets\sets.c(70) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(70) : warning C4028: formal parameter 1 different from
declaration
error: command 'E:\VisualC++NET2003\Vc7\bin\cl.exe' failed with exit status 2

The MSDN help gives a simple example of code raising compiler error C2099: // C2099.c
int j;
int *p;
j = *p; // C2099, *p is not a constant

The example code shows to me, that there is a good reason compiler
generates an error in that case.
j = *p; leads to an assignment of a random (and therefore maybe leading to a non deterministic crash of the executable during runtime) value to a
variable, what can't be intended in a deterministic program.
This is confusing, because the problem of the example code is not that
*p is not constant but rather that p is undefined aka uninitialized.

Humm..

Compiling the following program:

#include <stdio.h>
int main(void) {
int j;
int *p;
j = *p;
printf("%d\n",j); /* Makes sure the optimizer doesnt remove the
previous code */
return 0;
}

with

gcc -O3 -Wall main.c

gives me:

main.c: In function `main':
main.c:4: warning: `p' might be used uninitialized in this function

(And I get a Segmentation fault from running the executable.)

The -Wall flag enables, umm, as it is saying 'all' warnings
though perhaps not really all, and this flag + others is used
by the compilation command generated by distutils when
building with gcc.

I don't see any warnings when building Guppy.

So there should be no case (as easy to discover) as that in the
example.

So I am confused.

I was beginning to wonder if we were talking about the same file/code.
This code is from sets.c lines 66..71

static NyHeapDef nysets_heapdefs[] = {
{0, &NyMutBitSet_Type, (NyHeapDef_SizeGetter) mutbitset_indisize},
{0, &NyCplBitSet_Type, 0, cplbitset_traverse},
{0, &NyNodeSet_Type, nodeset_indisize, nodeset_traverse,
nodeset_relate},
{0}
};

The code in my sets.c file is lines 67..72:
static NyHeapDef nysets_heapdefs[] = {
{0, &NyMutBitSet_Type, (NyHeapDef_SizeGetter) mutbitset_indisize},
{0, &NyCplBitSet_Type, 0, cplbitset_traverse},
{0, &NyNodeSet_Type, nodeset_indisize, nodeset_traverse,
nodeset_relate},
{0}
};

Maybe you can explain what this declaration is good for and where the
identifiers are defined, so that I have a chance to fix it myself?
Currently I have no idea where to start and what is wrong with it.
It seems, that the only one not declared identifier is NyHeapDef_SizeGetter,
but this does not help because if I preceede the code with
extern NyHeapDef_SizeGetter
I get:

src\sets\sets.c(68) : warning C4091: 'extern ' : ignored on left of 'int
(__cdecl *)(PyObject *)' when no variable is declared
src\sets\sets.c(78) : error C2099: initializer is not a constant
src\sets\sets.c(78) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'NyHeapDef_SizeGetter'
src\sets\sets.c(79) : error C2099: initializer is not a constant
src\sets\sets.c(79) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(80) : error C2099: initializer is not a constant
src\sets\sets.c(80) : warning C4047: 'initializing' : 'PyTypeObject *'
differs in levels of indirection from 'int (__cdecl *)(PyObject *)'
src\sets\sets.c(80) : warning C4028: formal parameter 1 different from
declaration
src\sets\sets.c(80) : warning C4028: formal parameter 1 different from
declaration
error: command 'E:\VisualC++NET2003\Vc7\bin\cl.exe' failed with exit status
2

where the code at line 68 is:

extern NyHeapDef_SizeGetter; // line 68
// extern mutbitset_indisize;
// extern NyCplBitSet_Type;
// extern cplbitset_traverse;
// extern NyNodeSet_Type;
// extern nodeset_indisize;
// extern nodeset_traverse;
// extern nodeset_relate;

static NyHeapDef nysets_heapdefs[] = {
{0, &NyMutBitSet_Type, (NyHeapDef_SizeGetter) mutbitset_indisize},
{0, &NyCplBitSet_Type, 0, cplbitset_traverse},
{0, &NyNodeSet_Type, nodeset_indisize, nodeset_traverse,
nodeset_relate},
{0}
};


I can't see how there can be problems with initializers not being
constants here unless, perhaps if the compiler has a problem since
those functions (mutbitset_indisize etc) and the types that are used
as initializers are in separately compiled files. But gcc -Wall
-pedantic handles it and doesn't warn. I don't have the ANSI standard
but I have the 2nd edition of The C Programming Language by Kernighan
and Ritchie (1988, 'Based on Draft-Proposed ANSI C'), and it is saying

- quotes -

A8.7 Initialization
...

All the expressions in the initializer for a static object or array
must be constant expressions as described in &A7.19
...

A7.19 Constant Expressions

Syntactically, a constant expression is an expression restricted to a
subset of operators...
...

More latitude is permitted for the constant expressions of
initializers... Initializers must evaluate either to a constant or to
the address of a previously declared external or static object plus or
minus a constant.

- end quotes -

If this means the Microsoft .NET compiler is perhaps not compliant
with standard/ANSI C then since it was from 2003 maybe they have come
out with an update now that fixes this problem. I know, it may not
really help you because it may cost money, I don't know how long one
can get updates without paying. Alternatively, I think GCC is
available for Microsoft Windows although I don't know how it handles
the .NET architecture.

For me, if the case is according to hypothesis, and I would have to
rewrite the code to put all the functions and type objects in a single
file, it would be.. umm.. painful. (Though I could get around
it with #include trickery but it is still painful.)

Sverker


I don't know if it applies here, but in this context the extern keyword
comes to my mind.

Here is what MSDN says about it:
The extern keyword declares a variable or function and specifies that it has
external linkage (its name is visible from files other than the one in which
it's defined). When modifying a variable, extern specifies that the variable
has static duration (it is allocated when the program begins and deallocated
when the program ends). The variable or function may be defined in another
source file, or later in the same file. Declarations of variables and
functions at file scope are external by default.

Maybe it helps?

Claudio
Dec 2 '05 #7
"Claudio Grondi" <claudio.gro...@freenet.de> wrote: I don't know if it applies here, but in this context the extern keyword
comes to my mind.


[snip extracts from Microsoft docs]

Perhaps. But I suspect it isn't that simple since ...
I'd think even if I don't use the extern keyword the compiler
should be able to figure it out. (As a service to the programmer.)
And it shouldn't be very difficult to do.

I'll probably not try this out for a while,
but maybe you can check it yourself or ask someone that knows C.

Regards,
Sverker

Dec 3 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: modemer | last post by:
Hello, I got weird compiling message similar like following when I compiled my simple code on Sun 5.8 with CC WorkShop 6 update 2 C++ 5.3. CC -g -o myclass.o -c myclass.cpp CC -g -o main.o...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
2
by: Rudy Ray Moore | last post by:
Hi guys, I just upgraded to "Visual Studio .net 2003 7.1 c++" from VS6. Some things I like (proper for loop variable scoping, for example), but some other things are troubling me. One...
10
by: Christina N | last post by:
When compiling my ASP.Net application, VS puts the new DLL under the local cached directory 'VSWebCache' in stead of on the server. How can I make it save the DLL file on the server when compiling?...
0
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help compiling code dynamically it may involve some reflection so if any one is any good in that field or compiling code this would be a great time to show me what you know. by the way my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.