Page 1 of 1

printf Results Not Getting Displayed in Output View

Posted: Wed Jun 15, 2016 8:05 pm
by ColleenKobe
I have a problem that's been vexing me for a few days: I don't get compiler, linker, or execution error messages, but my program's printfs don't get displayed in the CodeLite Output View window. They DO get displayed if I run the program from a CMD window, but I'd sure like to see them in the output view.

I have a CodeLite workspace containing two projects.

1. Project MainProg contains a C++ main program.

2. Project Globals contains plain C code with some variable and function declarations.

Here are the files and results. Most of the code is commented out because I've been trying to track down the problem.

g_memory.c

Code: Select all

#include "g_memory.h"
#include "string.h"

// Set Up Compiler Options

#define CALL_TYPE __stdcall

#ifndef UNICODE
#define UNICODE
#endif

// int     g_banana;
// char    g_Debug_Filename    [g_mem_FILENAME_LENGTH];
// int     g_fruitbasket       [QTY_FRUITS];




    // *************************************************************************
    //                     S e t   a n d   G e t   g _ x
    // *************************************************************************
// DllExport void CALL_TYPE Get_g_fruitbasket (int New_Values [], int Length)
// {
//     int i = 0;
//     for (i = 0; i < Length; ++i)
//         New_Values [i] = g_fruitbasket [i];
// }
// DllExport void  CALL_TYPE Set_g_fruitbasket (int New_Values [], int Length)
// {
//     int i = 0;
//     for (i = 0; i < Length; ++i)
//         g_fruitbasket [i] = New_Values [i];
// }



    // *************************************************************************
    //                     S e t   a n d   G e t   g _ x
    // *************************************************************************
// DllExport char  CALL_TYPE Get_g_Debug_Filename (void)               { return (g_Debug_Filename); }
// DllExport void  CALL_TYPE Set_g_Debug_Filename (char * New_Value)   { g_Debug_Filename = New_Value; }
//
// char    g_Debug_Filename [g_mem_FILENAME_LENGTH];


//     // *************************************************************************
//     //                S e t   a n d   G e t   g _ b a n a n a
//     // *************************************************************************
// DllExport   int     CALL_TYPE Get_g_banana  (void)          { return (g_banana); }
// DllExport   void    CALL_TYPE Set_g_banana  (int New_Value) { g_banana = New_Value; }



//     // *************************************************************************
//     //                                 g _ S u m
//     // *************************************************************************
//
// DllExport   int CALL_TYPE   g_Sum  (int addend1, int addend2)
// {
//     double  actual_sum  = ZERO;
//     int     rc          = ZERO;
//
//     // Check for overflow and underflow.  If the sum is in range, return it.
//     // Otherwise, return the maximum or minimum value.
//
//     actual_sum  = (double) ((double) addend1 + (double) addend2);
//
//     if (actual_sum < (double) INT_MIN)
//         rc = ZERO;
//     else if ((double) INT_MAX < actual_sum)
//         rc = ZERO;
//     else
//         rc = actual_sum;
//     return (rc);
// }

//     // *************************************************************************
//     //                          g _ I n i t i a l i z e
//     // *************************************************************************
//
// DllExport   int CALL_TYPE   g_Initialize  (void)
// {
//     int i = 0;
//
//     g_banana    = 3;
//     memset  (g_Debug_Filename, '\0', g_mem_FILENAME_LENGTH);
//     strcpy  (g_Debug_Filename, "abc");
//
//     for (i = 0; i < QTY_FRUITS; ++i)
//         g_fruitbasket   [i] = i * 2 + 6;
//
//     return ((int) ZERO);
// }
g_memory.h

Code: Select all

#ifndef G_MEMORY_H
#define G_MEMORY_H

#ifdef __cplusplus
extern "C"
{
#endif

#define DllImport  __declspec(dllimport)
#define DllExport  __declspec(dllexport)
#define CALL_TYPE __stdcall

#define g_mem_FILENAME_LENGTH             255
#define INT_MAX                    2147483648
#define INT_MIN                   -2147483647
#define QTY_FRUITS                          3
#define ZERO                                0

// extern  int     g_banana;
// extern  char    g_Debug_Filename    [g_mem_FILENAME_LENGTH];
// extern  int     g_fruitbasket       [QTY_FRUITS];

// extern  DllExport   int     CALL_TYPE g_Sum             (int addend1, int addend2);
// extern  DllExport   int     CALL_TYPE g_Initialize      (void);
// extern  DllExport   void    CALL_TYPE Get_g_fruitbasket (int New_Values [], int Length);
// extern  DllExport   void    CALL_TYPE Set_g_fruitbasket (int New_Values [], int Length);
// extern  DllExport   int     CALL_TYPE Get_g_banana      (void);
// extern  DllExport   void    CALL_TYPE Set_g_banana      (int New_Value);

#ifdef __cplusplus
}
#endif

#endif // G_MEMORY_H
main.cpp

Code: Select all

#include <stdio.h>
#include "g_memory.h"

int main(int argc, char **argv)
{

//     int A1  = ZERO;
//     int A2  = ZERO;
//     int rc  = ZERO;
//     int Sum = ZERO;

    printf("You're doing great!!!\n");

    // Part 1: Testing the Variables and #defines.
//    Set_g_banana (ZERO);
//    printf("\nAFTER STEP 1: global variable g_banana  = %d (should be 0).\n", Get_g_banana());
//
//     rc = g_Initialize();
//     printf("\nAFTER STEP 2: rc from g_Initialize = %d; global variable g_banana  = %d (should be 3).\n", rc, Get_g_banana());
//
//     for (i = 0; i < QTY_FRUITS; ++i)
//     {
//         printf ("             g_fruitbasket [%d] = %d.", i, g_fruitbasket [i]);
//     }
//
//
//     Set_g_banana (7);
//
//
//     printf("\nAFTER STEP 3: global variable g_banana  = %d (should be 7).\n", Get_g_banana());
//
//     g_Debug_Filename [0] = 'o';
//     g_Debug_Filename [1] = 'k';
//     g_Debug_Filename [2] = '!';
//     g_Debug_Filename [3] = '\0';
//     printf("\n\nglobal variable g_Debug_Filename = <%s>.\n\n", g_Debug_Filename);
//     // Part 2: Testing the function calls.
//
//     fflush(stdout);
//
//     A1 =  5;
//     A2 = 11;
//     printf ("-------------------------------------------\n");
//     Sum = g_Sum(A1, A2);
//     printf("%d + %d = %d\n\n", A1, A2, Sum);
//
//     A1 =  INT_MIN + 1;
//     A2 =  -1;
//     printf ("--- Underflow Check 1 ---------------------------------------\n");
//     Sum = g_Sum(A1, A2);
//     printf("%d + %d = %d\n\n", A1, A2, Sum);
//
//     A1 =  INT_MIN + 1;
//     A2 =  -2;
//     printf ("--- Underflow Check 2 ---------------------------------------\n");
//     Sum = g_Sum(A1, A2);
//     printf("%d + %d = %d\n\n", A1, A2, Sum);
//
//     A1 =  INT_MAX - 1;
//     A2 =  1;
//     printf ("--- Overflow Check 1 ----------------------------------------\n");
//     Sum = g_Sum(A1, A2);
//     printf("%d + %d = %d\n\n", A1, A2, Sum);
//
//     A1 =  INT_MAX - 1;
//     A2 =  2;
//     printf ("--- Overflow Check 2 ----------------------------------------\n");
//     Sum = g_Sum(A1, A2);
//     printf("%d + %d = %d\n\n", A1, A2, Sum);

    fflush(stdout);

    return 0;
}
Compile and Link results

Code: Select all

C:\Windows\system32\cmd.exe /C C:/TDM-GCC-32/bin/mingw32-make.exe -e -f  "Globals.mk"  MakeIntermediateDirs && C:/TDM-GCC-32/bin/mingw32-make.exe -e -f  "Globals.mk"  all
----------Building project:[ Globals - Debug ]----------
C:/TDM-GCC-32/bin/gcc.exe -c  "F:/Prototypes_CPP_Console_Only/GlobalVariableTests/Globals/g_memory.c" -g -O0 -Wall   -o ./Debug/g_memory.c.o -I. -I../include/ -I. -I../include/
gcc -shared -fPIC -o ../RunFromHere/Globals.dll @"Globals.txt" -L. -L../RunFromHere/
====0 errors, 0 warnings====
C:\Windows\system32\cmd.exe /C C:/TDM-GCC-32/bin/mingw32-make.exe -e -f  "MainProg.mk"  MakeIntermediateDirs && C:/TDM-GCC-32/bin/mingw32-make.exe -e -f  "MainProg.mk"  all
----------Building project:[ MainProg - Debug ]----------
C:/TDM-GCC-32/bin/g++.exe  -c  "F:/Prototypes_CPP_Console_Only/GlobalVariableTests/MainProg/main.cpp" -g -O0 -Wall   -o ./Debug/main.cpp.o -I. -I../include/ -I.
C:/TDM-GCC-32/bin/mingw32-g++.exe -o ../RunFromHere/MainProg @"MainProg.txt" -L. -L../RunFromHere/ -L. -L../RunFromHere/  -lGlobals
====0 errors, 0 warnings====
Software Versions:

Code: Select all

CodeLite: 9.1.8
gcc: 4.9.3
tdm-gcc: 5.1.0.3
Windows 7: 6.1
wxCrafter: 2.5
wxWidgets: 3.1.0

Target platform: 32-bit
Target build: debug
What am I doing wrong? Where is that printf going? How do I get it to display in the Output View?

Thanks in advance!