Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 23rd, 2008, 7:18 PM   #1
null_ptr0
11 years old
 
Join Date: Nov 2007
Posts: 79
Rep Power: 1 null_ptr0 is on a distinguished road
multiple definition of variable

DevCpp with g++ is giving me errors about 3 of my variables declared in a header as multiple definitions, even though I use the #ifndef preprocessor command correctly.
Any help?

note: it occurs during link time
__________________
iload_0 iconst_1 ishl or
iload_0 iconst_2 idiv or
iload_0 iconst_2 iconst_1 imul idiv
[1] & [2] use the smallest stack size

Last edited by null_ptr0; Feb 23rd, 2008 at 7:45 PM. Reason: new error
null_ptr0 is offline   Reply With Quote
Old Feb 23rd, 2008, 7:23 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Re: from void * to C string?

(Edit: Fine, change your quesiton on me.)

Here it is in C. I'm not sure if C++ has different rules regarding void pointer typecasting, but hopefully it can be of use until someone else fills in the details for me.

C Syntax (Toggle Plain Text)
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void outstring(void *p) {
  5. char *s = (char *)p;
  6. printf("%s\n", s);
  7. }
  8.  
  9. int main() {
  10. outstring("Hello World!");
  11. return 0;
  12. }
Sane is offline   Reply With Quote
Old Feb 23rd, 2008, 7:33 PM   #3
null_ptr0
11 years old
 
Join Date: Nov 2007
Posts: 79
Rep Power: 1 null_ptr0 is on a distinguished road
Re: from void * to C string?

Quote:
Originally Posted by Sane View Post
Here it is in C. I'm not sure if C++ has different rules regarding void pointer typecasting, but hopefully it can be of use until someone else fills in the details for me.

C Syntax (Toggle Plain Text)
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void outstring(void *p) {
  5. char *s = (char *)p;
  6. printf("%s\n", s);
  7. }
  8.  
  9. int main() {
  10. outstring("Hello World!");
  11. return 0;
  12. }
fixed that with a dumb fix: i was suppose to use static_cast. new error now.
__________________
iload_0 iconst_1 ishl or
iload_0 iconst_2 idiv or
iload_0 iconst_2 iconst_1 imul idiv
[1] & [2] use the smallest stack size
null_ptr0 is offline   Reply With Quote
Old Feb 24th, 2008, 12:49 AM   #4
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,198
Rep Power: 5 grumpy is on a distinguished road
Re: from void * to C string?

If you want useful help, it is generally a good idea to provide information about what your problem actually is. For example, what error messages you are getting, and what compiler (or linker) is generating them?

Changing your question while someone is in the process of providing an answer to your original question is rather pointless too.
grumpy is offline   Reply With Quote
Old Feb 24th, 2008, 9:34 AM   #5
null_ptr0
11 years old
 
Join Date: Nov 2007
Posts: 79
Rep Power: 1 null_ptr0 is on a distinguished road
Re: from void * to C string?

Quote:
Originally Posted by grumpy View Post
If you want useful help, it is generally a good idea to provide information about what your problem actually is. For example, what error messages you are getting, and what compiler (or linker) is generating them?

Changing your question while someone is in the process of providing an answer to your original question is rather pointless too.
its okay, i finished it anyway. it was an error where i was including a header in two files, which were both being included into the same file. all's fixed. can someone lock?
__________________
iload_0 iconst_1 ishl or
iload_0 iconst_2 idiv or
iload_0 iconst_2 iconst_1 imul idiv
[1] & [2] use the smallest stack size
null_ptr0 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
An Attempt at a DBMS grimpirate PHP 8 Apr 17th, 2007 1:01 PM
Throwing an exception when using string constructor csrocker101 C# 3 Apr 8th, 2007 2:04 PM
Method not returning string csrocker101 C# 1 Apr 6th, 2007 6:45 PM
Help with breaking apart a string csrocker101 C# 6 Apr 6th, 2007 7:50 AM
function solomon_13000 Java 6 Apr 2nd, 2005 11:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC