C :: How To Share Imported DLL Functions Between Source Files

Nov 24, 2013

In general, my problem is that I've been trying to reorganize the project I and my group are working on into separate project files. Everything was working perfectly fine before, but now I'm facing the wrath of undefined reference errors when I try to call my DLL functions.

I have them declared and included in the central header file here :

Code:

/* DLL functions */
typedef void ( * t_wait )( int milliseconds, const int frames_per_seconds );
typedef clock_t ( * ft_timer )( int command, t_timer * timer_object ); /* clock_t is usually defined as long */
typedef void ( * t_SDL_errorexit )( const char * message );
typedef SDL_Surface * ( * t_load_image )( char * image_path, unsigned is_transparent );

[Code]...

Then I have them imported here :

Code:
/* ******************************************************** */
/* ********* win_error( char *, bool ) ********* */
/* ******************************************************** */
/* - Displays a GUI for a windows specific error message, */
/* pass true to it to have it exit the program, pass false */
/* to have it continue */
/* ******************************************************** */
extern void win_error( char * message, bool is_exit )
{
/* Note : win_error uses the Win32 Api */
/* ********************************** */
char buffer[BUFSIZ] = { 0 }; /*

[code]...

This doesn't work, as my compiler sees it that I am trying to call invalid functions, whereas I have made sure to import the functions before calling. Obviously my compiler can't tell that, and is trying to protect me from calling them.

The source files are compiled as C++, but I'm using C-style code instead of true C++ code.

Obviously I'm using Windows style DLL linking, but if the only ways to share imported functions are non-standard, only post ways that will work on as low as Windows XP.

I have tried to statically link them before, but that led to a problem that I posted a while back. Which led me to dynamically linking, which was problem-free until I separated my code into separate files.

View 13 Replies


ADVERTISEMENT

C++ :: Typedefs Automatically Imported In Header Files?

Jul 7, 2014

I recently noticed that I don't need to include the required header files inside header files that I have written myself. As as example, GLuint is defined using typedef unsigned int GLuint; inside glew.h. If I create a sample.hpp header file and mention GLuint without including glew.h, the compiler automatically works out that there is a typedef in glew.h. However, if I mention GLuint in a source file the compiler starts to complain. I have seen this happen in VS 2010 and 2013.

Edit: I should have mentioned that I am not including any other header files so I'm not indirectly including glew.h

In case you need to look at the code:

#ifndef CP_SHADER_LOADER_H
#define CP_SHADER_LOADER_H
namespace cp {

[Code].....

View 6 Replies View Related

C++ :: Share Values Between Functions In Same Class?

Mar 22, 2013

Code:

#ifndef CANDIES_H
#define CANDIES_H
#include <iostream>
#include <fstream>
#include <Global.h>
class Candies

[Code]...

Code:

#include "Candies.h"
#include <Windows.h>
#include <iostream>
#include <fstream>
#include <sstream>

[Code]...

When I tested it, the file name in getName() outputted the right file name. However the file name in loadName() does not print out anything in the console window.

I want it to be so that the strings in [I]name_addTXT.c_str() in both functions are equal.

View 4 Replies View Related

C++ :: How To Share Variables Between Two Header Files

Mar 16, 2012

Here is what I did,

Code:
// A.h
const int salary = 1000000;

// B.h
extern const int salary = 1000000;

But I still got multi-definition errors. How should I fix it?

View 6 Replies View Related

C :: How To Share Variable Value From One Source File To Other Header File

Dec 11, 2014

I wanted to share the value of a variable from Sender Program to Receive after program and want to calculate difference between send and receive. After studying Header file concept I program following three.

Now I am struck. How to to compile? I link all these file. I used following method:

Code:
gcc Sender.c -o Sender Sender.h
gcc Receiver.c -o Receiver Student.h

Then I run Sender and after that Receiver.I per my knowledge, Receiver should give difference but it gives error :

Code:
Receiver.c: In function "main":
Receiver.c:10:42: error: "Send" undeclared (first use in this function)
printf(" Total Receive is %d
",Receive-Send);

Code:
Sender.c
#include <stdio.h>
int Send ;
void main(){

[Code] ....

View 2 Replies View Related

Visual C++ :: Should Precompiled Header Files Also Be Included In Source Header Files?

Sep 16, 2013

When including a header file in stdafx.h, should that file still be included in the source file where it is actually used?

If it is included in both places, is the one in the source file ignored?

View 5 Replies View Related

C/C++ :: How To Get Multiple Source Files To Run One After The Other

May 16, 2012

I am trying to run multiple source files but right after the first one finishes running the program closes and doesn't move on ...

View 2 Replies View Related

C :: Accessing Pointers From Other Source Files

Oct 16, 2013

I've recently been learning GTK (though this question is not specific to GTK), and came across a situation that I was unsure how to best handle. Essentially, I've defined several pointers in one source file, and I want to access those pointers from other source files.

The structure of my GTK programs generally follow this pattern:

- "main.c": Define the main window and run GTK main
- "create_window.c": Create and arrange widget pointers in the main window
- "program_functions.c": All other source code for the project (several source files in reality)

In "create_window.c", I declare and define all my widget pointers (e.g. label). If I need to modify those widgets in "program_functions.c" for any reason (say, to change the value of a label), I need access to the pointers created in "create_window.c".

My first thought was to create a global struct of pointers in "create_window.c", and extern that struct to the other source files that need access to the pointers. The thing I don't like about this approach is spreading globals across my program.

My second idea was to create access functions in "create_window.c" where the necessary pointers are statically stored. The first time I call this function (immediately after creating a widget), a static copy of that pointer is stored in the function. Each time afterwards when I call that function (from other source files), I simply use that static pointer to access the widget of interest.

Example:
Code: void edit_label_1(GtkWidget *label_set, const char *string)
{
static GtkWidget *label = NULL;

[Code].....

Are either one of the approaches considered acceptable by standard practice?

View 2 Replies View Related

C :: Compile Multiple Source Files

Mar 7, 2013

How I can compile multiple source file in visual studio 2012 ???

View 1 Replies View Related

C++ :: Program Needs To Compile Various Source Files At Runtime

Oct 30, 2014

My program needs to compile various source files at runtime.What is the most elegant way to compile cross platform with g++ from within my program? Is there a gcc-library I can use? I know that I could use popen() to open a Unix pipe and call g++ as command line tool. But first it isn't really cross platform and second it doesn't seem elegant to me.

View 10 Replies View Related

C++ :: Reading Source Code From Uncompleted Files?

Jun 9, 2013

I know it sounds strange but I've seen things that have files which contain source code (usually in something in Python or such) and how this is read on run-time?

View 1 Replies View Related

C++ :: Including Header Files To Source File?

Jul 10, 2013

For example, I have the below files in a project called Calculate :

Source files : Calculate.cpp , Average.cpp (with out main)
Header files : Calculate.h , Average.h

I knew in general, we have to include Average.h to project header file Calculate.h to make it as part of project.

technical difference between adding header file (Average.h) to either project header file (Calculate.h) or project source file (Calculate.cpp) ?

I found no difference in an output. But, there must be technical difference.

View 3 Replies View Related

C++ :: Source Files Separation And Inter-related Classes

Feb 11, 2012

I have heard that people should implement their class member functions in files that are different from their class declaration files. But in cases there are multiple classes that are inter-related to each other, how will you review the source code ?

View 1 Replies View Related

Managed C++ And C++/CLI :: Breaking Up Large Class Into Manageable Source Files?

Feb 9, 2015

I'm trying to make sure my code is written in smaller modules, so my first step is to create my initialization process in and external file to load the necessary data from external sources and set up things like the content of drop down list boxes.

My first attempt failed to give me access to the combobox items add function so I moved that code back into the form1.h file:

Code:
public:
Form1(void) {
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
void AddDate(char *date, int ID)
{
this->comboBox1->Items->Add("line 1");
}

It compiles fine, but the call to it in my Initialize.cpp file

Code:
MarketView::Form1::AddDate("abs",1);
Gives error C2352: 'MarketView::Form1::AddDate' : illegal call of non-static member function

OK, so I change "void AddDate" to "static void AddDate" and now get the error that "static member functions do not have 'this' pointers" so I go back to the "MarketView::Form1::comboBox1" situation where there is no legal syntax after "Box1 to get me to Items->Add

I've been an old fashion programmer for over 47 years. It seems as is the concept of programming computers has changed from the concepts of logic to memorization of complex syntax.

There has to be a simple answer to do this other than to write thousands of lines of code in one Form1.h file. I refuse to believe that the new programming concepts will not allow you to write code in smaller more manageable modules.

What is the proper syntax for breaking up the larger file into more manageable chucks?

View 12 Replies View Related

C/C++ :: Reading From Files And Using Functions?

Mar 24, 2014

My question portion is attached. The code I have written is below.

#define _USE_MATH_DEFINES // for C++
#include <cmath>
#include <iostream>
#include <iomanip>

[Code].....

View 3 Replies View Related

C++ :: Creating Header Files With Functions

Oct 30, 2014

I currently have a running program "game.cpp" that runs a game of tic tack toe. I want to split the working functions into header files so that game.cpp isn't so cluttered. I have created two header files "displayBoard.h" and "gamePlay.h" but they wont compile because the functions are looking for variables that haven't been declared. First, here's the working code.

#include "displayBoard.h"
#include <iostream>
#include <limits> //This is required to catch invalid user input
class ticTacToe //A class to contain all our functions {

[Code] .....

View 11 Replies View Related

C++ :: Calling Functions From Text Files?

Jan 5, 2015

I'm working on a code that reads a text file and follows the instructions written in that file. An example of the text file:

*sum
11 4 61 2
1 2 0 14
17 99 1 1
*subtract
5 6 7
1 1 1
45 6 9

I want to read the text file line by line, each time I find an instruction (that is, the keywords *sum or *subtract) I want to make a summation (in the case of *sum) of all the numbers in each of the following lines, and repeat until the next instruction appear. So the text file above should generate:

78
17
118
-8
-1
30

That is:

11 + 4 + 61 + 2 = 78
1 + 2 + 0 + 14 = 17
17 + 99 + 1 + 1 = 118
5 - 6 - 7 = -8
1 - 1 - 1 = -1
45 - 6 - 9 = 30

how can I implement a dictionary(I'm guessing a dictionary is the best way to go here) so that when I read the string *sum i can call a function that does the summation of the following lines.

the size of the text file may be big (several mb) and the number of different instructions to search for may be in the magnitude of hundreds.

View 5 Replies View Related

C :: Putting Functions / Headers In Separate Files?

Aug 2, 2013

I have just learned about how one can put functions and headers in different files from the main() function. I was wondering if there is a rule of thumb of when and when not to separate the two, or if it's merely preference. Is there perhaps an "industry standard" regarding this, for those who program in C for a living?

View 4 Replies View Related

C# :: How To Share Variables Between 3 Classes

Apr 2, 2014

I am wondering how to share a variable in 3 classes. For example:

variable class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

[Code] ...

class that edits the variable:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1

[code]......

The actual program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1

[code]......

What should happen when this runs is this:

Variable changed in program: 0
Same variable changed in a different class: 1

Instead, this happens:

Variable changed in program: 0
Same variable changed in a different class: 0

View 7 Replies View Related

C/C++ :: Print Single Linked List Backward With Functions / Classes - Error Message Regarding Header Files

Oct 11, 2014

I'm trying to print a single linked list backward with functions/classes. I have created the main file and 3 header files. But I'm getting an error on one of the header files, linkedListIterator after adding #include "linkedListType.h". It says that "linkedLlistType.h" is calling itself. And when I try to run it, I get an error of "too many header files." I have tried changing the headers many times, but nothing seems to work.

.cpp file:

/*(Printing a single linked list backward) Include the functions reversePrint and recursiveReversePrint, as discussed in this chapter, in the class linkedListType. Also, write a program function to print a (single) linked list backward. (Use either the class unorderedLinkedList or the class orderedLinkedList to test your function.)*/

#include "linkedListType.h"
#include "orderedLinkedList.h"
#include "linkedListIterator.h"
#include <iostream>
using namespace std;
struct nodeType

[Code] ....

header files:
[URL] .... (error in this header file)
[URL] ....

View 9 Replies View Related

C++ :: Reinitialize Dynamic / Share Library?

Jan 23, 2013

I am getting some problem in a dynamic/share library I am using with my code. Restarting my application solves the problem.

tell me any safe way to reinitialize kind of mechanism for dynamic loaded libraries with minimum code changes in my application?

View 3 Replies View Related

C++ :: How To Share Information In Multi File Project

Dec 9, 2013

this last few days I've been coding this one particular file

Hero.cpp

namespace Hero {
namespace {
// all data here
}
}

then the code grew a bit to about 700 line

Then now I want to implement hero skill system It needs the access to data inside the unnamed namespace where I put just about everything.. but it's unnamed namespace, it's only valid within one file and I should hide all that data from Hero interface in Hero.h How should I do this ?

View 12 Replies View Related

C# :: How To Share Video File Between Multiple PC Over Internet

Jul 2, 2014

Basically i'm willing to create an application which could share Video,Mp3 Over the internet to my friends.

For suppose I'm hosting file on my PC, and i want to share "D" Drive to my friends but they aren't connected to my network locally. i want to share movies over the internet using a host and client application in c#.net.

the purpose of this application is very clear that that i want to share movies over the internet and they have to be able to watch movies on their PCs Except running my PC remotely.

View 8 Replies View Related

Visual C++ :: Creating Different Process And Share Data Between 2

Dec 8, 2014

I want to create 2 different easy processes in C++ 1st and then i wanted to share data between these 2 processes.

View 7 Replies View Related

C/C++ :: How To Access Linked List Functions From Stack Class Without Functions

Mar 20, 2014

I'm a little confused by my programming assignment this week. I've been working at it Wednesday and I've made progress but I'm still confused as to how I'm supposed to do this. The class I made is called Stack, and it's derived from a template class called StackADT. We also utilize a class called unorderedLinkedList, which is derived from a class called linkedList.

We're supposed to implement all of the virtual functions from stackADT in the Stack class. The Stack data is stored in a an unorderedLinkedList, so what I'm confused by is how to implement a few of the Stack functions because there are no functions in unorderedLinkedList which we could call to manipulate the data.

As you can see from my attached code, I'm really confused by how I'm supposed to implement the pop() and top() functions, and I also think my initializeList() function is wrong. We don't have any similar functions in unorderedLinkedList to call, so I'm at a loss of how i'd access my unorderedLinkedList. My initial thought was to call the similar functions in the class that unorderedLinkedList was derived from, linkedList, but I'm unsure of this is what we're supposed to do, or if theres actually a way to access my unorderedLinkedList without having to use the functions from the base class.

NOTE: We're not allowed to modify stackADT, unorderedLinkedList, and linkedList.

Stack.h

#include "stackADT.h"
#include "unorderedLinkedList.h"
template<class Type>
class Stack: public stackADT<Type>{
template <class T>
struct nodeType
{
T info;
nodeType<T> *link;

[Code]...

View 3 Replies View Related

C :: Program To Hide Files Behind Other Files Using Alternate Data Streams

Apr 5, 2013

I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.

The program is as follows:

Code:

#include <stdio.h>
#include <stdlib.h>
int main(void){
char hostfile[75], hiddenfile[75], hiddenFileName[15] ;
printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: ");
scanf("%75s", hostfile);

[Code]...

The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved