473,770 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using C to create a Static lib



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

The following are some of the excerpt of my codes:
********* MyFirstStaticLi b.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.
Nov 14 '05 #1
17 2197
Ralph <RA***@cwazy.RE MOVETHIS.co.uk> wrote:
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
Nov 14 '05 #2
kal
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<40******* *********@news. individual.net> ...

<OT>
Ralph <RA***@cwazy.RE MOVETHIS.co.uk> wrote:
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


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>
Nov 14 '05 #3
In <a5************ **************@ posting.google. com> k_*****@yahoo.c om (kal) writes:
<OT> <snip></OT>


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

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #4
k_*****@yahoo.c om (kal) wrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote in message news:<40******* *********@news. individual.net> ...
Ralph <RA***@cwazy.RE MOVETHIS.co.uk> wrote:
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.


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
Nov 14 '05 #5
Richard Bos <rl*@hoekstra-uitgeverij.nl> scribbled the following:
k_*****@yahoo.c om (kal) wrote:
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.


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

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- 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
Nov 14 '05 #6
kal
Da*****@cern.ch (Dan Pop) wrote in message news:<c9******* ***@sunnews.cer n.ch>...
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?"
Nov 14 '05 #7
kal <k_*****@yahoo. com> scribbled the following:
Da*****@cern.ch (Dan Pop) wrote in message news:<c9******* ***@sunnews.cer n.ch>...
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?

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"C++. C++ run. Run, ++, run."
- JIPsoft
Nov 14 '05 #8
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
kal <k_*****@yahoo. com> scribbled the following:
Da*****@cern.ch (Dan Pop) wrote in message news:<c9******* ***@sunnews.cer n.ch>...
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
Nov 14 '05 #9
In <40************ ****@news.indiv idual.net> rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
Joona I Palaste <pa*****@cc.hel sinki.fi> wrote:
kal <k_*****@yahoo. com> scribbled the following:
> Da*****@cern.ch (Dan Pop) wrote in message news:<c9******* ***@sunnews.cer n.ch>...
>> 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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #10

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

Similar topics

16
4346
by: 4Space | last post by:
I've hit something of a snag. Problem: In a DSP application we have data profiles with a varying number of points. We have a number of Discrete Fourier transforms that are optimised for a specific number of points. Currently, any client of these DFT classes must switch on the number of points in the profile and instanciate the correct DFT algorithm.
4
7711
by: Jerry | last post by:
I am trying to read a physical sector off of the disk (the boot sector for drive C:) from C#. I have no problems doing it from a C/C++ application using the Win32 API CreateFile and ReadFile. However, when I attempt to use PInvoke to do the very same thing in C# the data read in is somehow being altered from what is on disk. Several of the bytes are being changed from their original value to 0x3f!?!?! Anyone have any ideas as to what I...
5
6804
by: rettigcd | last post by:
I have several classes that all have the same static member: class A{ public static string Table = "TableA"; } class B{ public static string Table = "TableB"; }
5
4580
by: Anders Borum | last post by:
Hello! Whilst refactoring an application, I was looking at optimizing a ModelFactory with generics. Unfortunately, the business objects created by the ModelFactory doesn't provide public constructors (because we do not allow developers to instantiate them directly). Because our business objects are instantiated very frequently, the idea of using reflection sounds like a performance killer (I haven't done any tests on this, but the...
14
3287
by: Steve Teeples | last post by:
I don't understand why I cannot use a property to modify data within a struct. Can someone tell me why I get the error "Cannot modify the return value of "myData.TheData" because it is not a variable. Here is what breaks. struct Data { public Data(){} private int someData;
25
2148
by: David Sanders | last post by:
Hi, As part of a simulation program, I have several different model classes, ModelAA, ModelBB, etc., which are all derived from the class BasicModel by inheritance. model to use, for example if the parameter model_name is "aa", then choose ModelAA. Currently I do this as follows:
3
8298
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
8
18286
by: =?Utf-8?B?Q2hyaXMgRmluaw==?= | last post by:
I am trying to make a minor modification to the code below and need some assistance. Currently this code is using the java.util, java.util.zip, and java.io assemblies from the vjslib.dll assembly. This code works fine by taking file(s) from disk and creating a zip file to disk. I need to modify this code to read a file from a byte array and then output the zip file to a byte array (all done in memory instead of disk). The reason for...
3
4846
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function pointers (delegates). I assume I need to use the array< T keyword to allocate an array of delegates, and then initialize the array by setting each array element to the pointers (handles) of the functions I'll be invoking. I've been trying to...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.