2009/07/31

Visual Studio 2005 - Warning LNK 4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification

The above warning occurs as a result of a clash between two features of the Visual Studio development suite and can be eliminated by either disabling support for "Edit and Continue" or eliminating Incremental Compilation. The first allows you to edit code while debugging when stopped at a break point. The second specifies whether linking is done incrementally or not (that is, one included library at a time). Linking incrementally can result in larger file sizes and occassionally "jump thunks," which, I believe, are libraries that require multiple memory hops to reach.

If you link a module that was compiled with /ZI, which implies an internal linker option called /EDITANDCONTINUE, and a module that was compiled with /OPT:REF, /OPT:ICF, or /INCREMENTAL:NO, which imply no /EDITANDCONTINUE, you will get LNK4075.

The property controlling "edit and continue" can be changed in the Project Properties Pages -> Project Configuration -> C/C++ -> Debug Information Format, whereas the property specifies if linking should be done incrementally can be changed in the Project Properties Pages -> Project Configuration -> Linker -> Enable Incremental Linking.

2009/07/30

C# - Passing Pointer / Pointer-to-Pointer as Input Parameter to DLL Methods

C Method Declaration

int TestMethod1(Struct1** handle);

int TestMethod2(Struct2* handle);




C# Dll Import

[DllImport("TestMethods.dll")]

private static extern int TestMethod1(ref IntPtr ptrHandle);

[DllImport("TestMethods.dll")]

private static extern int TestMethod2(IntPtr ptrHandle);




C# Calling Dll Methods

IntPtr ptrHandle = IntPtr.Zero;

ptrHandle = Marshal.AllocHGlobal(IntPtr.Size);

TestMethod1(ref ptrHandle);

TestMethod2(ptrHandle);

Marshal.FreeHGlobal(ptrHandle);

2009/07/24

C# - Convert Hexadecimal String into Byte Array

Hexadecimal String to Byte Array

public static byte[] StringToBytes(String s)

{

byte[] output = new byte[s.Length / 2];

for (int i = 0; i < i =" i">

{

String stringByte = s.Substring(i, 2);

output[i / 2] = Convert.ToByte(stringByte, 16);

}

return output;

}


2009/07/23

C# - Returning Multiple Values in A Method

Read From File
public class mathClass
{
public static int TestOut(out int iVal1, out int iVal2)
{
iVal1 = 10;
iVal2 = 20;
return 0;
}
public static void Main()
{
int i, j; // variable need not be initialized
Console.WriteLine(TestOut(out i, out j));
Console.WriteLine(i);
Console.WriteLine(j);
}
}


C# - Read From File and Write To File

Read from File

using System.IO;

public class FileClass

{

public static void Main()

{

ReadFromFile("c:\\MyTextFile.txt");

}

static void ReadFromFile(string filename)

{

StreamReader SR;

string S;

SR=File.OpenText(filename);

S=SR.ReadLine();

while(S!=null)

{

Console.WriteLine(S);

S=SR.ReadLine();

}

SR.Close();

}

}



Write from File

using System.IO;

public class FileClass

{

public static void Main()

{

WriteToFile();

}

static void WriteToFile()

{

StreamWriter SW;

SW=File.CreateText("c:\\MyTextFile.txt");

SW.WriteLine("God is greatest of them all");

SW.WriteLine("This is second line");

SW.Close();

Console.WriteLine("File Created SucacessFully");

}

}

Google Analytics

Blog Archive

Followers