using C to create a Static lib

R

Ralph

Hi all,
Recently I have tried to create a static lib using MS VC++.

The following are some of the excerpt of my codes:


********* MyFirstStaticLib.c *******************

#include <stdlib.h>
#include <string.h>

int getA(int a, int b){
....

}

int getB(int a, int b){
....

}

****************************************

Both function 'getA' and 'getB' will be used in my other program.

I compiling my other program... I alway got "__cdecl int getA()" errors
same fot 'getB' function.

Anyone know the cause?

Thanks.
 
R

Richard Bos

Ralph said:
Recently I have tried to create a static lib using MS VC++.

Note that creating libraries is system-specific, and therefore
off-topic. However...
Both function 'getA' and 'getB' will be used in my other program.

I compiling my other program... I alway got "__cdecl int getA()" errors
same fot 'getB' function.

Anyone know the cause?

....you might check that you are compiling (both the library and the
program which uses it) in C mode, not as C++. Ditto for linking and/or
library-collecting.

Richard
 
K

kal

(e-mail address removed) (Richard Bos) wrote in message
Note that creating libraries is system-specific, and therefore
off-topic. However...


...you might check that you are compiling (both the library and the
program which uses it) in C mode, not as C++. Ditto for linking and/or
library-collecting.

Richard

1. You need to do more reading about creating libraries.

2. Do not use functions names like "getA". The "A" won't make
your function name unique. Most of the MS library functions
are implemented in two versions, one appended with A (for Ascii)
and the other appended with W (for Wide char/Unicode).

3. When you implement a library, always specify the calling
convention. MS VC has __cdecl, __stdcall and __fastcall.
Generallly you should use __stdcall but the default is __cdecl.
There are compiler options (/Gz, /Gd) to specify which
convention to use as the default.

4. Distribute your library with a headerfile.

5. Post brief but complete information on here. It does not seem
that "__cdecl int getA()" is the complete error message.

</OT>
 
R

Richard Bos

1. You need to do more reading about creating libraries.

No, I don't. Be careful whom you address.
2. Do not use functions names like "getA". The "A" won't make
your function name unique. Most of the MS library functions
are implemented in two versions, one appended with A (for Ascii)
and the other appended with W (for Wide char/Unicode).

If M$ VC++ declares the function getA() when it is asked to compile an
ISO C program, it is a vile, malodorous, miscreant abomination. That
identifier is in the user's namespace, and it is the OP's full right to
use it. It isn't even a very unlikely name to occur. Any implementation
which prevents an ISO C program from defining a function called getA()
is severely broken.
3. When you implement a library, always specify the calling
convention. MS VC has __cdecl, __stdcall and __fastcall.

This is massively off-topic.
4. Distribute your library with a headerfile.

Obviously, but how is that pertinent to the problem?
5. Post brief but complete information on here.

No, don't. Post it somewhere where making libraries with M$ VC++ is
on-topic.

Richard
 
J

Joona I Palaste

If M$ VC++ declares the function getA() when it is asked to compile an
ISO C program, it is a vile, malodorous, miscreant abomination.

In other words, a rather usual M$ product. =)

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"When a man talks dirty to a woman, that's sexual harassment. When a woman talks
dirty to a man, that's 14.99 per minute + local telephone charges!"
- Ruben Stiller
 
K

kal

When your post is off topic from one end to the other, you prepend the
[OT] tag to the subject line.

Sorry about that. I really ought not to have posted that one. But the
OP seemed to be adrift without a paddle and since I happened to know a
little bit about that...

P.S. I have often wondered, "why HELVETICA?"
 
J

Joona I Palaste

kal said:
When your post is off topic from one end to the other, you prepend the
[OT] tag to the subject line.
Sorry about that. I really ought not to have posted that one. But the
OP seemed to be adrift without a paddle and since I happened to know a
little bit about that...
P.S. I have often wondered, "why HELVETICA?"

What "why Helvetica"? What does Helvetica have to do with this?
 
R

Richard Bos

Joona I Palaste said:
kal said:
When your post is off topic from one end to the other, you prepend the
[OT] tag to the subject line.
Sorry about that. I really ought not to have posted that one. But the
OP seemed to be adrift without a paddle and since I happened to know a
little bit about that...
P.S. I have often wondered, "why HELVETICA?"

What "why Helvetica"? What does Helvetica have to do with this?

I presume he means "Why does Dan Pop have an address in Switzerland?"
And I presume the answer is because Dan Pop has a job in Switzerland...

Richard
 
D

Dan Pop

In said:
Joona I Palaste said:
kal said:
(e-mail address removed) (Dan Pop) wrote in message When your post is off topic from one end to the other, you prepend the
[OT] tag to the subject line.
Sorry about that. I really ought not to have posted that one. But the
OP seemed to be adrift without a paddle and since I happened to know a
little bit about that...
P.S. I have often wondered, "why HELVETICA?"

What "why Helvetica"? What does Helvetica have to do with this?

I presume he means "Why does Dan Pop have an address in Switzerland?"
And I presume the answer is because Dan Pop has a job in Switzerland...

A presumption flatly contradicted by Dan Pop's signature block...

Dan
 
M

Martin Dickopp

Joona I Palaste said:
kal said:
(e-mail address removed) (Dan Pop) wrote in message When your post is off topic from one end to the other, you prepend the
[OT] tag to the subject line.
Sorry about that. I really ought not to have posted that one. But the
OP seemed to be adrift without a paddle and since I happened to know a
little bit about that...
P.S. I have often wondered, "why HELVETICA?"

What "why Helvetica"? What does Helvetica have to do with this?

I presume he means "Why does Dan Pop have an address in Switzerland?"
And I presume the answer is because Dan Pop has a job in Switzerland...

IIRC, CERN's main computing center is located France. At least a few
years ago, when the question of whether it is in Switzerland or France
was of utmost importance to me, I presumed it is in France...

Martin
 
C

CBFalconer

Dik T. Winter said:
But what has a From header to do with the place where someone works, or
lives, or whatever?

It is the only connection his present day posts show with
Switzerland, or Helvitica. Which (for some unknown and possibly
benighted reason) became a matter of urgent curiosity to someone
here, since snipped.
 
M

Mark McIntyre

It is the only connection his present day posts show with
Switzerland, or Helvitica.

What do my From: headers show? Any obvious connection with where I live or
work?
 
R

Richard Bos

Ok, s/has/had/, then.

Moreover, when that From: is from cern.ch, one might reasonably presume
that its user either legally has a relation with CERN, or is using that
address illegitimately. Since I don't presume Dan to use an address like
that without reason, I must presume him to still have some kind of
working relationship with CERN. A presumption born out, despite his own
protests, by the institute featured in his sigblock...
What do my From: headers show? Any obvious connection with where I live or
work?

No, but then, spamcop.net are a well-known mail service, not a research
institute.

Your doubly mangled sig shows, btw, that you need to get a new newsfeed.
A less commercial one. _Or_ that you need to smack the current one,
hard.

Richard
 
D

Dan Pop

In said:
Ok, s/has/had/, then.


Moreover, when that From: is from cern.ch, one might reasonably presume
that its user either legally has a relation with CERN, or is using that
address illegitimately.

The only valid presumption is that I have a computer account at CERN.
From here, one can easily infer an unspecified relationship with CERN.
Since I don't presume Dan to use an address like
that without reason, I must presume him to still have some kind of
working relationship with CERN. A presumption born out, despite his own
protests, by the institute featured in his sigblock...

Having a relationship of unspecified nature with CERN (which is the only
thing that can be correctly inferred from my From: headers) doesn't mean
having a job at CERN.

FYI: only a tiny fraction of the people with a cern.ch email address have
a job at CERN. All the others have a relationship of a different nature
with CERN, most of them being CERN *users*.

Dan
 
D

Dan Pop

In said:
[email protected] (Richard Bos) said:
Joona I Palaste said:
kal <[email protected]> scribbled the following:
(e-mail address removed) (Dan Pop) wrote in message When your post is off topic from one end to the other, you prepend the
[OT] tag to the subject line.

Sorry about that. I really ought not to have posted that one. But the
OP seemed to be adrift without a paddle and since I happened to know a
little bit about that...

P.S. I have often wondered, "why HELVETICA?"

What "why Helvetica"? What does Helvetica have to do with this?

I presume he means "Why does Dan Pop have an address in Switzerland?"
And I presume the answer is because Dan Pop has a job in Switzerland...

IIRC, CERN's main computing center is located France. At least a few
years ago, when the question of whether it is in Switzerland or France
was of utmost importance to me, I presumed it is in France...

OTOH, anyone with a CERN job counts as having a job in Switzerland...

The exact location of the computing center (in France, a few metres from
the Swiss border) was a real PITA back when France didn't allow encrypted
traffic on its territory: we *had* to allow telnet connections to our
public access machines.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top