Skip to content

Commit

Permalink
Full compatibility with msvc 12.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkm authored and kkm000 committed May 12, 2015
1 parent c826fe8 commit 16c1ba0
Show file tree
Hide file tree
Showing 35 changed files with 258 additions and 132 deletions.
2 changes: 1 addition & 1 deletion extlibs/openfstwin-1.4.1/include/fst/const-fst.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class ConstFst : public ImplToExpandedFst< ConstFstImpl<A, U> > {
public:
friend class StateIterator< ConstFst<A, U> >;
friend class ArcIterator< ConstFst<A, U> >;
template <class F, class G> void friend Cast(const F &, G *);
template <class F, class G> friend void Cast(const F &, G *);

typedef A Arc;
typedef typename A::StateId StateId;
Expand Down
2 changes: 1 addition & 1 deletion extlibs/openfstwin-1.4.1/include/fst/fst-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ template <class A, class B, class C> class ArcMapFst;
template <class A> class ProjectFst;
template <class A, class B, class S> class RandGenFst;
template <class A> class RelabelFst;
template <class A, class T = DefaultReplaceStateTable<A>, class C = DefaultCacheStore<A> > class ReplaceFst;
template <class A, class T = DefaultReplaceStateTable<A, ssize_t>, class C = DefaultCacheStore<A> > class ReplaceFst;
template <class A> class RmEpsilonFst;
template <class A> class UnionFst;

Expand Down
2 changes: 1 addition & 1 deletion extlibs/openfstwin-1.4.1/include/fst/generic-register.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GenericRegister {
virtual EntryType LoadEntryFromSharedObject(const KeyType &key) const {
#ifdef FST_NO_DYNAMIC_LINKING
return EntryType();
#elif //Added PD
#else //Added PD
string so_filename = ConvertKeyToSoFilename(key);
void *handle = dlopen(so_filename.c_str(), RTLD_LAZY);
if (handle == 0) {
Expand Down
2 changes: 2 additions & 0 deletions msbuild/kaldi.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<Link>
<SubSystem>Console</SubSystem>
<!--<LinkIncremental>false</LinkIncremental>-->
<AdditionalDependencies>$(KaldiLibFiles);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(KaldiLibPaths);%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions msbuild/kaldi.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Text="Invalid BuildStage. Are you running the top-level build project?"/>
<Error Condition=" '$(BuildStage)' == 'Binary' and '$(KaldiBinaryTarget)' == '' "
Text="For the Binary and Test build stages, KaldiBinaryTarget= specification is required. Are you running the top-level build project?"/>
<Error Condition=" '$(Platform)' != 'Win32' and '$(Platform)' != 'x64' "
Text="You have set Platfrom to a value other than 'Win32' or 'x64'. This will not work."/>
<Warning Condition=" '$(KaldiCUDA)' == 'true' and '$(CUDAFound)' == '' "
Text="CUDA has been requested in kaldi.user.props but not found. Install CUDA 6.5 (not supporting other versions at the moment)." />
</Target>
Expand Down
20 changes: 15 additions & 5 deletions msbuild/kaldi.user.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,26 @@
<KaldiRootPath>../</KaldiRootPath>

<!-- Additional preprocessor defines. -->
<KaldiDefines></KaldiDefines>
<KaldiDefines>HAVE_OPENFST_GE_10400</KaldiDefines>

<!-- Additional include directories. At the least, point to openfstwin installation. -->
<KaldiIncludePaths></KaldiIncludePaths>
<KaldiIncludePaths>
C:\projects\kaldi\kaldi\extlibs\openfstwin-1.4.1\include;
C:\projects\kaldi\kaldi\extlibs\pthreads-2.9.1\include;
</KaldiIncludePaths>

<!-- Additional library directories. -->
<KaldiLibPaths></KaldiLibPaths>
<!-- Additional library directories. Will be different for 32 and 64 builds. -->
<KaldiLibPaths Condition =" '$(Platform)' == 'Win32' ">
C:\projects\kaldi\kaldi\extlibs\openfstwin-1.4.1\lib\x32;
C:\projects\kaldi\kaldi\extlibs\pthreads-2.9.1\lib\x86;
</KaldiLibPaths>
<KaldiLibPaths Condition =" '$(Platform)' == 'x64' ">
C:\projects\kaldi\kaldi\extlibs\openfstwin-1.4.1\lib\x64;
C:\projects\kaldi\kaldi\extlibs\pthreads-2.9.1\lib\x64;
</KaldiLibPaths>

<!-- Additional link libraries. -->
<KaldiLibFiles></KaldiLibFiles>
<KaldiLibFiles>openfst.lib;pthreadVC2.lib</KaldiLibFiles>

</PropertyGroup>
</Project>
4 changes: 1 addition & 3 deletions src/base/kaldi-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
#include <sstream>
#include <cstdio>

#ifdef _MSC_VER
#define NOEXCEPT(Predicate)
#elif __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
#if _MSC_VER >= 0x1400 || !defined(MSC_VER) && __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)
#define NOEXCEPT(Predicate) noexcept((Predicate))
#else
#define NOEXCEPT(Predicate)
Expand Down
13 changes: 1 addition & 12 deletions src/base/kaldi-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,10 @@ typedef float BaseFloat;
}

#ifdef _MSC_VER
namespace kaldi {
typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
typedef __int16 int16;
typedef __int32 int32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
typedef float float32;
typedef double double64;
}
#include <basetsd.h>
#define ssize_t SSIZE_T
#endif

#else
// we can do this a different way if some platform
// we find in the future lacks stdint.h
#include <stdint.h>
Expand All @@ -59,6 +49,5 @@ typedef int64_t int64;
typedef float float32;
typedef double double64;
} // end namespace kaldi
#endif

#endif // KALDI_BASE_KALDI_TYPES_H_
7 changes: 4 additions & 3 deletions src/base/kaldi-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
# include <windows.h>
#endif

#if defined(_MSC_VER)
#pragma warning(disable: 4244 4056 4305 4800 4267 4996 4756 4661)
#if _MSC_VER < 1400
#define __restrict__
#else
#define __restrict__ __restrict
#endif

#if defined(_MSC_VER)
#pragma warning(disable: 4244 4056 4305 4800 4267 4996 4756 4661)
#endif

#ifdef HAVE_POSIX_MEMALIGN
Expand Down
12 changes: 9 additions & 3 deletions src/bin/align-text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ bool IsNotToken(const std::string &token) {
return ! kaldi::IsToken(token);
}

int main(int argc, char *argv[]) {
using namespace kaldi;
typedef kaldi::int32 int32;
namespace kaldi {

int main(int argc, char *argv[]) {
try {
const char *usage =
"Computes alignment between two sentences with the same key in the\n"
Expand Down Expand Up @@ -133,3 +132,10 @@ int main(int argc, char *argv[]) {
return -1;
}
}

} //namespace kaldi


int main(int argc, char *argv[]) {
return kaldi::main(argc, argv);
}
7 changes: 6 additions & 1 deletion src/bin/extract-ctx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "tree/build-tree-questions.h"
#include "fst/fstlib.h"

using namespace kaldi;
namespace kaldi {

using std::vector;

Expand Down Expand Up @@ -212,4 +212,9 @@ int main(int argc, char *argv[]) {
}
}

} //namespace kaldi


int main(int argc, char *argv[]) {
return kaldi::main(argc, argv);
}
9 changes: 7 additions & 2 deletions src/bin/phones-to-prons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "fst/fstlib.h"
#include "fstext/fstext-lib.h"

namespace kaldi {

// Create FST that accepts the phone sequence, with any number
// of word-start and word-end symbol in between each phone.
void CreatePhonesAltFst(const std::vector<int32> &phones,
Expand Down Expand Up @@ -60,10 +62,8 @@ void CreatePhonesAltFst(const std::vector<int32> &phones,
}

int main(int argc, char *argv[]) {
using namespace kaldi;
using fst::VectorFst;
using fst::StdArc;
typedef kaldi::int32 int32;
try {
const char *usage =
"Convert pairs of (phone-level, word-level) transcriptions to\n"
Expand Down Expand Up @@ -220,4 +220,9 @@ int main(int argc, char *argv[]) {
}
}

} //namespace kaldi


int main(int argc, char *argv[]) {
return kaldi::main(argc, argv);
}
11 changes: 8 additions & 3 deletions src/bin/post-to-phone-post.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
#include "hmm/transition-model.h"
#include "hmm/posterior.h"

namespace kaldi {

int main(int argc, char *argv[]) {
try {
using namespace kaldi;
typedef kaldi::int32 int32;

const char *usage =
"Convert posteriors to phone-level posteriors\n"
"See also: post-to-pdf-post, post-to-weights, get-post-on-ali\n"
Expand Down Expand Up @@ -75,3 +74,9 @@ int main(int argc, char *argv[]) {
}
}

} //namespace kaldi


int main(int argc, char *argv[]) {
return kaldi::main(argc, argv);
}
9 changes: 6 additions & 3 deletions src/gmmbin/gmm-decode-nbest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "lat/kaldi-lattice.h" // for CompactLatticeArc
#include "fstext/lattice-utils.h" // for ConvertLattice

using namespace kaldi;
namespace kaldi {

fst::Fst<fst::StdArc> *ReadNetwork(std::string filename) {
// read decoding network FST
Expand Down Expand Up @@ -67,8 +67,6 @@ fst::Fst<fst::StdArc> *ReadNetwork(std::string filename) {

int main(int argc, char *argv[]) {
try {
typedef kaldi::int32 int32;

const char *usage =
"Decode features using GMM-based model, producing N-best lattice output.\n"
"Note: this program was mainly intended to validate the lattice generation\n"
Expand Down Expand Up @@ -245,4 +243,9 @@ int main(int argc, char *argv[]) {
}
}

} //namespace kaldi


int main(int argc, char *argv[]) {
return kaldi::main(argc, argv);
}
16 changes: 8 additions & 8 deletions src/kwsbin/generate-proxy-keywords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// See the Apache 2 License for the specific language governing permissions and
// limitations under the License.


#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "fstext/fstext-utils.h"
Expand Down Expand Up @@ -53,15 +52,16 @@ bool PrintProxyFstPath(const VectorFst<StdArc> &proxy,
}
}

using namespace fst;
using kaldi::int32;
using kaldi::uint64;
using kaldi::BasicVectorHolder;
using kaldi::ParseOptions;
using kaldi::SequentialInt32VectorReader;
using kaldi::TableWriter;

int main(int argc, char *argv[]) {
try {
using namespace kaldi;
using namespace fst;
typedef kaldi::int32 int32;
typedef kaldi::uint64 uint64;
typedef StdArc::StateId StateId;
typedef StdArc::Weight Weight;

const char *usage =
"Convert the keywords into in-vocabulary words using the given phone\n"
"level edit distance fst (E.fst). The large lexicon (L2.fst) and\n"
Expand Down
14 changes: 9 additions & 5 deletions src/kwsbin/kws-index-union.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
#include "lat/kaldi-kws.h"
#include "lat/kws-functions.h"

using namespace fst;
using kaldi::int32;
using kaldi::uint64;
using kaldi::KwsLexicographicArc;
using kaldi::KwsLexicographicFst;
using kaldi::ParseOptions;
using kaldi::SequentialTableReader;
using kaldi::TableWriter;

int main(int argc, char *argv[]) {
try {
using namespace kaldi;
using namespace fst;
typedef kaldi::int32 int32;
typedef kaldi::uint64 uint64;

const char *usage =
"Take a union of the indexed lattices. The input index is in the T*T*T semiring and\n"
"the output index is also in the T*T*T semiring. At the end of this program, encoded\n"
Expand Down
26 changes: 17 additions & 9 deletions src/kwsbin/kws-search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,25 @@ class VectorFstToKwsLexicographicFstMapper {

}

using namespace fst;
using kaldi::int32;
using kaldi::uint64;
using kaldi::BasicVectorHolder;
using kaldi::DecodeLabelUid;
using kaldi::EncodeLabel;
using kaldi::KwsLexicographicArc;
using kaldi::KwsLexicographicFst;
using kaldi::ParseOptions;
using kaldi::RandomAccessTableReader;
using kaldi::SequentialTableReader;
using kaldi::TableWriter;
using kaldi::VectorFstToKwsLexicographicFstMapper;

int main(int argc, char *argv[]) {
typedef KwsLexicographicArc Arc;
typedef Arc::Weight Weight;
typedef Arc::StateId StateId;
try {
using namespace kaldi;
using namespace fst;
typedef kaldi::int32 int32;
typedef kaldi::uint32 uint32;
typedef kaldi::uint64 uint64;
typedef KwsLexicographicArc Arc;
typedef Arc::Weight Weight;
typedef Arc::StateId StateId;

const char *usage =
"Search the keywords over the index. This program can be executed parallely, either\n"
"on the index side or the keywords side; we use a script to combine the final search\n"
Expand Down
29 changes: 24 additions & 5 deletions src/kwsbin/lattice-to-kws-index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,32 @@
#include "lat/kws-functions.h"
#include "fstext/epsilon-property.h"

using fst::VectorFst;
using kaldi::int32;
using kaldi::uint64;
using kaldi::BaseFloat;
using kaldi::ClusterLattice;
using kaldi::CompactLattice;
using kaldi::CompactLatticeStateTimes;
using kaldi::CompactLatticeStateTimes;
using kaldi::CreateFactorTransducer;
using kaldi::DoFactorDisambiguation;
using kaldi::DoFactorMerging;
using kaldi::KwsLexicographicArc;
using kaldi::KwsLexicographicFst;
using kaldi::KwsProductFst;
using kaldi::MaybeDoSanityCheck;
using kaldi::OptimizeFactorTransducer;
using kaldi::ParseOptions;
using kaldi::RandomAccessInt32Reader;
using kaldi::RandomAccessTableReader;
using kaldi::RemoveLongSilences;
using kaldi::SequentialCompactLatticeReader;
using kaldi::SequentialTableReader;
using kaldi::TableWriter;

int main(int argc, char *argv[]) {
try {
using namespace kaldi;
using fst::VectorFst;
typedef kaldi::int32 int32;
typedef kaldi::uint64 uint64;

const char *usage =
"Create an inverted index of the given lattices. The output index is in the T*T*T\n"
"semiring. For details for the semiring, please refer to Dogan Can and Muran Saraclar's"
Expand Down
Loading

0 comments on commit 16c1ba0

Please sign in to comment.